adventofcode-2020/13/part2

33 lines
619 B
Plaintext
Raw Permalink Normal View History

#!/usr/bin/python3
import time
def shuttle_generator():
with open("input") as fh:
now = int(fh.readline())
for i, x in enumerate(fh.readline().split(",")):
if x != "x":
x = int(x)
yield i, x
shuttle = shuttle_generator()
def check(t, tests):
for i, n in tests:
if (t + i) % n != 0:
return False
return True
t = 0
step = 1
n = 1
tests = []
while True:
if check(t, tests):
print(t, "matches", tests)
time.sleep(2)
step *= n
i, n = next(shuttle)
tests.append((i, n))
t += step