23 lines
428 B
Python
23 lines
428 B
Python
|
|
||
|
with open('input') as f:
|
||
|
groups = []
|
||
|
sum_ = 0
|
||
|
for line in f:
|
||
|
line = line.strip()
|
||
|
if line == '':
|
||
|
if sum_ > 0:
|
||
|
groups.append(sum_)
|
||
|
sum_ = 0
|
||
|
else:
|
||
|
sum_ += int(line)
|
||
|
|
||
|
a = max(groups)
|
||
|
groups.remove(max(groups))
|
||
|
b = max(groups)
|
||
|
groups.remove(max(groups))
|
||
|
c = max(groups)
|
||
|
groups.remove(max(groups))
|
||
|
|
||
|
print(a + b + c)
|
||
|
|