advent-of-code/2022/day01/part2.py

32 lines
404 B
Python
Raw Normal View History

2022-12-02 08:48:39 +01:00
"""
Part 2
"""
print("Hello World!")
file = open("input/input", "r")
ELVES = []
current = 0
for line in file.readlines():
line = line.strip()
if line == "":
ELVES.append(current)
current = 0
else:
line = int(line)
current += line
ELVES.append(current)
ELVES.sort()
ELVES = list(reversed(ELVES))
answer = ELVES[0] + ELVES[1] + ELVES[2]
print(answer)