22 lines
460 B
Python
22 lines
460 B
Python
|
#!/usr/bin/env python
|
||
|
# 2022 - Advent Of Code 1 - part 2
|
||
|
|
||
|
# file = 'input_example.txt'
|
||
|
file = 'input2.txt'
|
||
|
|
||
|
calories = []
|
||
|
with open(file, encoding="utf-8") as f:
|
||
|
accum = 0
|
||
|
for line in f.readlines():
|
||
|
if line == '\n':
|
||
|
# next elf
|
||
|
calories.append(accum)
|
||
|
accum = 0
|
||
|
else:
|
||
|
accum += int(line)
|
||
|
calories.append(accum)
|
||
|
|
||
|
calories.sort(reverse=True)
|
||
|
print(calories[0:3])
|
||
|
print(sum(calories[0:3]))
|