Advent of Code 2022 Day 1

Author

Nathan Moore

— 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?

with open('data-2022-01.txt', 'r') as f:
    inp = f.read().splitlines()

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)

# 72511
72511

— 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:])

# 212117
212117