advent_of_code/2022/1/1.py

21 lines
412 B
Python
Raw Normal View History

2022-12-01 10:34:34 +01:00
#!/usr/bin/env python
# 2022 - Advent Of Code 1
# file = 'input_example.txt'
file = 'input.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)
print(calories)
print(max(calories))