Solve day 6

This commit is contained in:
Nettika
2023-12-10 18:44:26 -08:00
parent 001eeb692f
commit 720def8fa9
3 changed files with 67 additions and 0 deletions

21
06/puzzle.py Normal file
View File

@@ -0,0 +1,21 @@
from typing import NamedTuple
class Race(NamedTuple):
time: int
distance: int
def solve(input: list[Race]):
permutations_total = 1
for race in input:
strategies_total = 0
for hold_time in range(race.time):
race_time = race.time - hold_time
realized_distance = race_time * hold_time
if realized_distance > race.distance:
strategies_total += 1
permutations_total = permutations_total * strategies_total
return permutations_total