Complete day 13, part 1

This commit is contained in:
Peter J. Holzer 2020-12-13 23:09:29 +01:00 committed by Peter J. Holzer
parent 4bdfb05300
commit 216f590993
2 changed files with 14 additions and 0 deletions

2
13/input Normal file
View File

@ -0,0 +1,2 @@
1008833
19,x,x,x,x,x,x,x,x,41,x,x,x,x,x,x,x,x,x,643,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,17,13,x,x,x,x,23,x,x,x,x,x,x,x,509,x,x,x,x,x,37,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,29

12
13/part1 Executable file
View File

@ -0,0 +1,12 @@
#!/usr/bin/python3
with open("input") as fh:
now = int(fh.readline())
ids = [int(x) for x in fh.readline().split(",") if x != "x"]
min_dt = now # arbitrary large number
for id in ids:
dt = -now % id
if dt < min_dt:
print(id, dt, id * dt)
min_dt = dt