-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAOC_Day13_Part2_v2.py
53 lines (38 loc) · 990 Bytes
/
AOC_Day13_Part2_v2.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import copy
import math
File = open("Day13_Input.txt", "r")
Lines = File.readlines()
BusTimes = Lines[1].strip().split(',')
Busses = []
Indices = []
for i in range(0,len(BusTimes)):
if BusTimes[i] != "x":
Busses.append(float(BusTimes[i]))
Indices.append(i)
MaxStep = max(Busses)
MaxIndex = Indices[Busses.index(MaxStep)]
print(Indices)
TimeCorrection= [x - MaxIndex for x in Indices]
print(Busses)
print(TimeCorrection)
print(MaxStep,MaxIndex)
condition1 = False
StartTime = 0
T0 = 0
TimeStampDelta = MaxStep
Timestamp = T0
time = 0
stepsize = 1
print('starting loop')
for i in range(0,len(Busses)-1):
print(Busses[i])
condition = False
stepsize *= Busses[i]
print(stepsize)
while condition == False:
print(time)
nextdeparture = time + Indices[i+1]
if nextdeparture % Busses[i+1] == 0:
condition = True
else:
time += stepsize