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
Logan G ae592b71af
Since everyone wanted me to use lists for D1, here you go
Also, zombie, your PR kinda sucked so I deleted it and made my own
2022-12-03 15:39:19 -07:00

22 lines
457 B
Python

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}')