advent-of-code/2022/d01/ex2/ex2.py

22 lines
404 B
Python
Raw Permalink Normal View History

2022-12-01 09:57:27 +01:00
#!/usr/bin/env python
import sys
def solve(input: list[list[int]]) -> int:
totals = sorted(map(lambda l: sum(l, start=0), input), reverse=True)
return sum(totals[:3])
def main() -> None:
input = [
[int(line) for line in group.splitlines()]
for group in sys.stdin.read().split("\n\n")
if group
]
print(solve(input))
if __name__ == "__main__":
main()