aoc2022/01/2022-12-01-golf.py
2022-12-02 19:58:12 +01:00

10 lines
467 B
Python
Executable file

#!/usr/bin/env python3
# Readable
with open("01/2022-12-01-input.txt") as f:
elves_calories = [[int(j) for j in i] for i in [x.split("\n") for x in f.read().split("\n\n")]]
print(sorted([sum(x) for x in elves_calories])[-1])
print(sum(sorted([sum(x) for x in elves_calories])[-3:]))
# One-liner
with open("01/2022-12-01-input.txt") as f: print(sorted([sum(x) for x in [[int(j) for j in i] for i in [x.split("\n") for x in f.read().split("\n\n")]]])[-1])