This repository has been archived on 2023-12-03. You can view files and clone it, but cannot push or open issues or pull requests.
thomas_2022/day_1/main2.py

23 lines
428 B
Python
Raw Normal View History

2022-12-02 20:13:46 -05:00
with open('input') as f:
groups = []
sum_ = 0
for line in f:
line = line.strip()
if line == '':
if sum_ > 0:
groups.append(sum_)
sum_ = 0
else:
sum_ += int(line)
a = max(groups)
groups.remove(max(groups))
b = max(groups)
groups.remove(max(groups))
c = max(groups)
groups.remove(max(groups))
print(a + b + c)