Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def day15_2():
- with open("input15.txt", "r") as file:
- data = file.read().split(",")
- last_seen = {int(n): i+1 for i, n in enumerate(data[:-1])}
- turn = len(data) + 1
- num = int(data[-1])
- while turn <= 30000000:
- if num not in last_seen:
- last_seen[num] = turn - 1
- next_num = 0
- else:
- next_num = turn - last_seen[num] - 1
- last_seen[num] = turn - 1
- num = next_num
- turn += 1
- return num
Add Comment
Please, Sign In to add comment