aoc2022/1/b.py

17 lines
348 B
Python

elves = []
with open("input.txt") as f:
current = 0
for line in f:
line = line.strip()
if line == "":
elves.append((len(elves), current, ))
current = 0
else:
current += int(line)
elves.sort(key=lambda x: x[1], reverse=True)
print(sum([elves[0][1], elves[1][1], elves[2][1]]))