37 lines
782 B
Python
37 lines
782 B
Python
import re
|
|
|
|
with open("data.txt") as file:
|
|
lines = [line.rstrip() for line in file]
|
|
|
|
times = []
|
|
distances = []
|
|
|
|
for line in lines:
|
|
if line == '':
|
|
print('Tühi rida')
|
|
continue
|
|
if line.startswith("Time: "):
|
|
temp = re.findall(r'\d+', line)
|
|
times = list(map(int, temp))
|
|
continue
|
|
if line.startswith("Distance: "):
|
|
temp = re.findall(r'\d+', line)
|
|
distances = list(map(int, temp))
|
|
continue
|
|
|
|
print(times)
|
|
print(distances)
|
|
|
|
x = 1
|
|
for attempt in range(0, len(times)):
|
|
waystowin = 0
|
|
time = times[attempt]
|
|
distance = distances[attempt]
|
|
for i in range(1, time):
|
|
if i * (time-i) > distance:
|
|
# print(f"Võidan, {i*(time-i)}")
|
|
waystowin += 1
|
|
x *= waystowin
|
|
|
|
print(x)
|