 After solving Part 1 of Day 1 I could unlock the second challenge. It’s a slight variation of the first.

Find the top three Elves carrying the most Calories. How many Calories are those Elves carrying in total?

``````calories = """1000
2000
3000

4000

5000
6000

7000
8000
9000

10000"""
``````

The test data stays the same.

Additionally we now need to add all calculated sums for each elf into a list together with the index of the original data.
After that we can sort the list and look at the first three elements:

``````def test_calc_overall_max_calories():
calories_inventory = []
list_all_cal = calories.split("\n\n")
for i, list_cal in enumerate(list_all_cal):
list_individual_cal = [int(x) for x in list_cal.split("\n")]
sum_cal = sum(list_individual_cal)
calories_inventory.append((sum_cal, i))

calories_inventory.sort(reverse=True)
assert calories_inventory == (24000, 3)
assert calories_inventory == (11000, 2)
assert calories_inventory == (10000, 4)

``````

Now we can read in the complete data set from part 1

``````def test_calc_overall_max_calories_from_file():
with open("aoc_data_01.txt", "r") as f:

calories_inventory = []
list_all_cal = data.split("\n\n")
for i, list_cal in enumerate(list_all_cal):
list_individual_cal = [int(x) for x in list_cal.split("\n")]
sum_cal = sum(list_individual_cal)
calories_inventory.append((sum_cal, i))

calories_inventory.sort(reverse=True)

assert calories_inventory == (67027, 12)
assert calories_inventory == (65333, 27)
assert calories_inventory == (64931, 234)

assert calories_inventory + calories_inventory + calories_inventory == 197291
``````