advent_of_code/2023/6/6.py
kleph 3c900f39ee
All checks were successful
continuous-integration/drone/push Build is passing
2023 - Day 6 part 1
2023-12-07 02:37:52 +01:00

27 lines
614 B
Python

#!/usr/bin/env python
# 2023 - Advent Of Code 6
import re
# file = 'input_example.txt'
file = 'input.txt'
races = []
with open(file, encoding="utf-8") as f:
times = re.findall(r"\s+(\d+)+\s?", f.readline())
distances = re.findall(r"\s+(\d+)+\s?", f.readline())
races = list(zip([int(x) for x in times], [int(x) for x in distances]))
print(races)
res = 1
for race in races:
count = 0
for tpress in range(1, race[0]):
nb = tpress * (race[0] - tpress)
if nb > race[1]:
count += 1
# print(f'{tpress}: {nb}')
print(count)
res *= count
print(res)