mirror of
https://github.com/thib8956/advent-of-code.git
synced 2024-12-26 05:46:29 +00:00
2022 day 1
This commit is contained in:
parent
02b4ec05db
commit
d9be62b784
14
2022/day1/day1.py
Normal file
14
2022/day1/day1.py
Normal file
@ -0,0 +1,14 @@
|
||||
def main(content):
|
||||
inventories = [x.rstrip().split("\n") for x in content.split("\n\n")]
|
||||
calories = sorted((sum(int(y) for y in x) for x in inventories), reverse=True)
|
||||
print("Part 1: ", calories[0])
|
||||
print("Part 2: ", sum(calories[:3]))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
import sys
|
||||
infile = sys.argv[1]
|
||||
with open(infile) as f:
|
||||
content = f.read()
|
||||
main(content)
|
||||
|
2244
2022/day1/input.txt
Normal file
2244
2022/day1/input.txt
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user