adventofcode/2022/01/02.py
2022-12-01 18:13:18 +01:00

19 lines
393 B
Python
Executable File

#!/usr/bin/env python3
INPUT_FILE = 'input'
def main():
content = list(map(str.strip, open(INPUT_FILE, 'r').readlines()))
elfs = []
cal_sum = 0
for line in content:
if line == '':
elfs.append(cal_sum)
cal_sum = 0
continue
cal_sum += int(line)
elfs.sort()
print(sum(elfs[-3:]))
if __name__ == '__main__':
main()