Skip to content

Commit 83c5af4

Browse files
committed
add day 1.py file
0 parents  commit 83c5af4

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

1.caloriecounting.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
from heapq import heappop, heappush
2+
3+
lst = []
4+
counter = 1
5+
total = 0
6+
7+
while True:
8+
try:
9+
line = input()
10+
11+
if not line:
12+
heappush(lst, (-total, counter))
13+
total = 0
14+
15+
elif line == 'STOP':
16+
for _ in range(3):
17+
highest = heappop(lst)
18+
print(-highest[0])
19+
20+
else:
21+
total += int(line)
22+
23+
except EOFError:
24+
break
25+
26+
27+
28+

0 commit comments

Comments
 (0)