diff --git a/py/aoc/__init__.py b/py/aoc/__init__.py index db133a6..56541d3 100644 --- a/py/aoc/__init__.py +++ b/py/aoc/__init__.py @@ -2,9 +2,10 @@ import sys import argparse from pathlib import Path -from .y2022 import d04 +from .y2022 import d01, d04 DAYS = { + "2022_01": y2022.d01.solve, "2022_04": y2022.d04.solve, } diff --git a/py/aoc/y2022/d01.py b/py/aoc/y2022/d01.py new file mode 100644 index 0000000..ef4c5d1 --- /dev/null +++ b/py/aoc/y2022/d01.py @@ -0,0 +1,8 @@ +def solve(inputstr): + elves = [] + for elfstr in inputstr.strip().split("\n\n"): + elf = sum(int(cal) for cal in elfstr.split()) + elves.append(elf) + elves.sort() + print(f"Part 1: {elves[-1]}") + print(f"Part 2: {sum(elves[-3:])}")