From f5a99b876d3ff19834fde909194836d0864d8569 Mon Sep 17 00:00:00 2001 From: Tibor Bizjak Date: Sat, 4 Mar 2023 15:34:36 +0100 Subject: [PATCH] Done with day 1. --- day01.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 day01.py diff --git a/day01.py b/day01.py new file mode 100644 index 0000000..b5405a6 --- /dev/null +++ b/day01.py @@ -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)