Skip to content

Instantly share code, notes, and snippets.

@zach2good
Created December 1, 2022 16:53
Show Gist options
  • Save zach2good/4e53f5c5000bde51a44556bd9afd07e2 to your computer and use it in GitHub Desktop.
Save zach2good/4e53f5c5000bde51a44556bd9afd07e2 to your computer and use it in GitHub Desktop.
aoc2022_d01.py
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