-
Notifications
You must be signed in to change notification settings - Fork 0
/
Day06.py
29 lines (22 loc) · 805 Bytes
/
Day06.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
input = open("Day06-input.txt", "r")
lines = input.read().splitlines()
for index, line in enumerate(lines):
lines[index] = line.split(":")[1].strip()
def removeEmptyElementsFromList(list):
return [value for value in list if value != '']
timeSplit = lines[0].split(" ")
distanceSplit = lines[1].split(" ")
times = removeEmptyElementsFromList(timeSplit)
distances = removeEmptyElementsFromList(distanceSplit)
times = list(map(int, times))
distances = list(map(int, distances))
result = 1
for index, time in enumerate(times):
waysToBeatTheRecord = 0
for i in range (0, time + 1):
speed = i
distanceTravalled = (time - i) * speed
if distanceTravalled > 0 and distanceTravalled > distances[index]:
waysToBeatTheRecord += 1
result = result * waysToBeatTheRecord
print(result)