Skip to content

Instantly share code, notes, and snippets.

@dartharva
Created December 2, 2022 08:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dartharva/c44d62d909c1cfc83f5771bc61efd030 to your computer and use it in GitHub Desktop.
Save dartharva/c44d62d909c1cfc83f5771bc61efd030 to your computer and use it in GitHub Desktop.
Advent of Code 2022, Day 1 - Simple, verbose python
with open('input.txt', 'r') as file:
calories = file.read().split('\n\n')
sums = [sum(int(x) for x in line.split()) for line in calories]
print(max(sums)) #Problem 1
top_3 = sorted(sums, reverse = True)[:3]
print(top_3, sum(top_3)) #Problem 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment