Complete day 15, part 1

This commit is contained in:
Peter J. Holzer 2020-12-26 21:51:16 +01:00 committed by Peter J. Holzer
parent 5189f9d0d0
commit 3c78737aec
1 changed files with 29 additions and 0 deletions

29
15/part1 Executable file
View File

@ -0,0 +1,29 @@
#!/usr/bin/python3
import sys
import time
from pprint import pprint
turn = 0
num = None
last_turn = {}
for a in sys.argv[1:]:
last_turn[num] = turn
turn += 1
num = int(a)
pprint(last_turn)
while True:
if num in last_turn:
new_num = turn - last_turn[num]
else:
new_num = 0
last_turn[num] = turn
num = new_num
turn += 1
print(turn, num)
if turn >= 2020:
break