adventofcode2022/day1/day1.py
2022-12-02 23:05:27 -07:00

23 lines
559 B
Python

if __name__ == "__main__":
elves = {}
with open('input', 'r') as f:
elf = 0
elves[0] = 0
for line in f:
if line.strip() == '':
elf += 1
elves[elf] = 0
else:
elves[elf] += int(line.strip())
largest = max(elves, key=elves.get)
print(f'Index: {largest}\nValue: {elves[largest]}')
top3 = 0
for i in range(3):
largest = max(elves, key=elves.get)
top3 += elves[largest]
del elves[largest]
print(f'Top 3: {top3}')