[py] Solve 2022_01

This commit is contained in:
Joscha 2022-12-04 14:00:18 +01:00
parent 30e11343d1
commit 476d3bcccc
2 changed files with 10 additions and 1 deletions

View file

@ -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,
}

8
py/aoc/y2022/d01.py Normal file
View file

@ -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:])}")