Brute force Python solution:
def check_ascending(n): return "".join(sorted(n)) == n def check_repeat(n): for digit1, digit2 in zip(n, n[1:]): if digit1 == digit2: return True def check_two_consecutive_digits(n): repeat_count = 0 for n1, n2 in zip(n, n[1:]): if n1 == n2: repeat_count += 1 else: if repeat_count == 1: return True repeat_count = 0 return repeat_count == 1 p1_count = 0 p2_count = 0 for n in range(134792, 675811): n = str(n) if check_ascending(n): if check_repeat(n): p1_count += 1 if check_two_consecutive_digits(n): p2_count += 1 print(f"Part 1: {p1_count}") print(f"Part 2: {p2_count}")
For me, this was 100x easier than day 3.
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Brute force Python solution:
For me, this was 100x easier than day 3.