[py] Solve 2022_01
This commit is contained in:
parent
30e11343d1
commit
476d3bcccc
2 changed files with 10 additions and 1 deletions
|
|
@ -2,9 +2,10 @@ import sys
|
||||||
import argparse
|
import argparse
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from .y2022 import d04
|
from .y2022 import d01, d04
|
||||||
|
|
||||||
DAYS = {
|
DAYS = {
|
||||||
|
"2022_01": y2022.d01.solve,
|
||||||
"2022_04": y2022.d04.solve,
|
"2022_04": y2022.d04.solve,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
8
py/aoc/y2022/d01.py
Normal file
8
py/aoc/y2022/d01.py
Normal 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:])}")
|
||||||
Loading…
Add table
Add a link
Reference in a new issue