Looked up solution for part 2 of day 13
This commit is contained in:
parent
5d9ede4659
commit
84a8e32404
16
13/part2.py
Normal file
16
13/part2.py
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
|
||||||
|
def getBuses(filename):
|
||||||
|
with open(filename, "r") as f:
|
||||||
|
f.readline()
|
||||||
|
return {i:int(x) for i, x in enumerate(f.readline().split(",")) if x != "x"}
|
||||||
|
|
||||||
|
buses = getBuses("input.txt")
|
||||||
|
step = list(buses.values())[0]
|
||||||
|
t = step
|
||||||
|
|
||||||
|
for dt, busId in buses.items():
|
||||||
|
while (t + dt) % busId != 0:
|
||||||
|
t += step
|
||||||
|
step *= busId
|
||||||
|
|
||||||
|
print(t)
|
Loading…
Reference in New Issue
Block a user