Complete day 15, part 2
This commit is contained in:
parent
3c78737aec
commit
f9fe016835
|
@ -0,0 +1,30 @@
|
|||
#!/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
|
||||
if turn % 100000 == 0:
|
||||
print(turn, num)
|
||||
if turn == 30000000:
|
||||
break
|
||||
|
Loading…
Reference in New Issue