with open('data-2022-01.txt', 'r') as f:
inp = f.read().splitlines()Advent of Code 2022 Day 1
— Day 1: Calorie Counting —
We are going on a journey to collect some magical star fruit for the reindeer. The elves are carrying some rations for the journey.
Find the Elf carrying the most Calories. How many total Calories is that Elf carrying?
This looks like a loop to me
cal = [0]
for i in inp:
if i == '':
cal.append(0)
else:
cal[-1] += int(i)
max(cal)
# 7251172511
— Part Two —
Find the top three Elves carrying the most Calories. How many Calories are those Elves carrying in total?
cal.sort()
cal[-3:]
sum(cal[-3:])
# 212117212117