[py] Solve 2022_01
This commit is contained in:
parent
30e11343d1
commit
476d3bcccc
2 changed files with 10 additions and 1 deletions
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