1
0

Solved part 1 of day 13

This commit is contained in:
Rokas Puzonas 2020-12-13 18:56:54 +02:00
parent 33bfb88910
commit 94dcb766cd
3 changed files with 24 additions and 0 deletions

2
13/input.txt Normal file
View File

@ -0,0 +1,2 @@
1000186
17,x,x,x,x,x,x,x,x,x,x,37,x,x,x,x,x,907,x,x,x,x,x,x,x,x,x,x,x,19,x,x,x,x,x,x,x,x,x,x,23,x,x,x,x,x,29,x,653,x,x,x,x,x,x,x,x,x,41,x,x,13

20
13/part1.py Normal file
View File

@ -0,0 +1,20 @@
import math
def getNotes(filename):
with open(filename, "r") as f:
return {
"departTime": int(f.readline()),
"IDs": [int(i) for i in f.readline().split(",") if i != "x"]
}
notes = getNotes("input.txt")
departTime = notes["departTime"]
earliestID = 0
earliestTime = math.ceil(departTime/notes["IDs"][0])*notes["IDs"][0]
for ID in notes["IDs"]:
time = math.ceil(departTime/ID)*ID
if earliestTime > time:
earliestTime = time
earliestID = ID
print(earliestID*(earliestTime-departTime))

2
13/test.txt Normal file
View File

@ -0,0 +1,2 @@
939
7,13,x,x,59,x,31,19