This repository has been archived on 2023-12-02. You can view files and clone it, but cannot push or open issues or pull requests.
logan_2022/day1/day1-alt.py

23 lines
457 B
Python
Raw Normal View History

if __name__ == "__main__":
elves = []
with open('input', 'r') as f:
sum_ = 0
for line in f:
if line.strip() == '':
elves.append(sum_)
sum_ = 0
else:
sum_ += int(line.strip())
elves.append(sum_)
elves.sort(reverse=True)
largest = elves[0]
print(f'Max Value: {largest}')
top3 = elves[0] + elves[1] + elves[2]
print(f'Top 3: {top3}')