Created
December 1, 2022 16:53
-
-
Save zach2good/4e53f5c5000bde51a44556bd9afd07e2 to your computer and use it in GitHub Desktop.
aoc2022_d01.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
input = """ | |
INPUT HERE | |
""" | |
totals = {} | |
index = 0 | |
amounts = input.split("\n\n") | |
for elf in amounts: | |
calories = elf.split("\n") | |
if '' in calories: | |
calories.remove('') | |
totals[index] = 0 | |
for calorie in calories: | |
totals[index] = totals[index] + int(calorie) | |
index = index + 1 | |
in_order = sorted(totals.values(), reverse=True) | |
print("Part 1:") | |
print(in_order[0]) | |
print("Part 2:") | |
print(in_order[0] + in_order[1] + in_order[2]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment