AOC/2022/day01/part2.py

13 lines
264 B
Python
Raw Permalink Normal View History

2024-08-29 11:12:29 -04:00
f = open("file", "r")
str = f.read()
f.close()
lst = []
for paquet in str.split("\n\n"):
Sum = 0;
for sub_paquet in paquet.split("\n"):
if (sub_paquet != ""):
Sum += int(sub_paquet)
lst.append(Sum);
lst.sort();
print(sum(lst[-3:]))