12 lines
398 B
Python
12 lines
398 B
Python
with open("input.txt", "r") as f:
|
|
elves = f.read().split('\n\n')
|
|
elf_calories = []
|
|
for elf in elves:
|
|
snacks = elf.split('\n')
|
|
calories = 0
|
|
for snack in snacks:
|
|
calories += int(snack)
|
|
elf_calories.append(calories)
|
|
elf_calories = sorted(elf_calories, reverse=True) # high -> low
|
|
print(f"Part 1: {elf_calories[0]}") # Top elf
|
|
print(f"Part 2: {sum(elf_calories[:3])}") # Top 3 elves |