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.py

25 lines
506 B
Python
Raw Normal View History

2022-12-02 16:56:31 -05:00
if __name__ == "__main__":
elves = []
2022-12-02 16:56:31 -05:00
with open('input', 'r') as f:
sum_ = 0
2022-12-02 16:56:31 -05:00
for line in f:
if line.strip() == '':
elves.append(sum_)
sum_ = 0
2022-12-02 16:56:31 -05:00
else:
sum_ += int(line.strip())
2022-12-02 16:56:31 -05:00
elves.append(sum_)
largest = max(elves)
print(f'Max Value: {largest}')
2022-12-02 17:16:20 -05:00
top3 = 0
for i in range(3):
largest = max(elves)
top3 += largest
elves.remove(largest)
2022-12-02 17:16:20 -05:00
print(f'Top 3: {top3}')