Done with day 1.

master
Tibor Bizjak 2023-03-04 15:34:36 +01:00
parent 22a9ca179a
commit f5a99b876d
1 changed files with 24 additions and 0 deletions

24
day01.py 100644
View File

@ -0,0 +1,24 @@
#!/usr/bin/env python3
def naive_fuel(mass : int) -> int:
return mass // 3 - 2
def calc_fuel(mass : int) -> int:
fuel_mass = naive_fuel(mass)
if fuel_mass < 0:
return 0
return fuel_mass + calc_fuel(fuel_mass)
def preproc(puzzle_input : str):
return list(map(int, puzzle_input.split()))
def partI(modules):
return sum(map(naive_fuel, modules))
def partII(modules):
return sum(map(calc_fuel, modules))
import solver
tests = solver.Tests()
tests.add(1969, partI=654, partII=966)
tests.add(100756, partI=33583, partII=50346)