advent_of_code/2023/6/6_2.py
kleph ed9e80e7c9
All checks were successful
continuous-integration/drone/push Build is passing
2023 - Day 6 part 2
2023-12-07 02:44:19 +01:00

26 lines
571 B
Python

#!/usr/bin/env python
# 2023 - Advent Of Code 6 - part 2
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())
big_time = int("".join(times))
print(big_time)
big_dist = int("".join(distances))
print(big_dist)
res = 1
count = 0
for tpress in range(1, big_time):
nb = tpress * (big_time - tpress)
if nb > big_dist:
count += 1
# print(f'{tpress}: {nb}')
print(count)