Created
December 2, 2022 08:01
-
-
Save dartharva/c44d62d909c1cfc83f5771bc61efd030 to your computer and use it in GitHub Desktop.
Advent of Code 2022, Day 1 - Simple, verbose python
This file contains 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
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