22 lines
416 B
Python
22 lines
416 B
Python
with open("input") as file:
|
|
cal: list = []
|
|
elf = 1
|
|
|
|
calories = 0
|
|
for line in file.readlines():
|
|
|
|
if line.strip() == "":
|
|
|
|
cal.append((elf, calories))
|
|
|
|
elf += 1
|
|
calories = 0
|
|
continue
|
|
|
|
calories += int(line.strip())
|
|
|
|
cal.sort(key=lambda x: -x[1])
|
|
|
|
print("part1:", cal[0])
|
|
print("part2:", sum(list(map(lambda x: x[1], cal[:3]))))
|