aoc2020/15/2.py

25 lines
489 B
Python
Raw Normal View History

def play_number_of_turns(turns):
content = [2,0,6,12,1,3]
2020-12-15 10:04:21 +01:00
spoken = [0] * turns
new_spoken = 0
turn = 1
for c in content:
spoken[c] = turn
turn += 1
2020-12-15 10:04:21 +01:00
last_turn = 0
while turn <= turns:
if not last_turn:
new_spoken = 0
else:
new_spoken = turn - 1 - last_turn
2020-12-15 10:04:21 +01:00
last_turn = spoken[new_spoken]
spoken[new_spoken] = turn
turn += 1
2020-12-15 10:04:21 +01:00
print(new_spoken)
play_number_of_turns(30000000)