adventOfCode/challenges/2022/01-calorieCounting/py/__init__.py
AKP 652bf4833b
Fix type hints
Signed-off-by: AKP <tom@tdpain.net>
2022-12-01 11:39:36 +00:00

21 lines
530 B
Python

from typing import *
from aocpy import BaseChallenge
def parse(instr: str) -> List[List[int]]:
return [map(int, x.split("\n")) for x in instr.strip().split("\n\n")]
class Challenge(BaseChallenge):
@staticmethod
def one(instr: str) -> int:
parsed = parse(instr)
x = [sum(y) for y in parsed]
return max(x)
@staticmethod
def two(instr: str) -> int:
parsed = parse(instr)
x = [sum(y) for y in parsed]
x = list(sorted(x, reverse=True))
return sum(x[:3])