Uncheated
This commit is contained in:
parent
6a3d307033
commit
f8d4de16f6
3 changed files with 37 additions and 0 deletions
15
day_1/main.py
Normal file
15
day_1/main.py
Normal file
|
@ -0,0 +1,15 @@
|
|||
|
||||
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)
|
||||
|
||||
print(max(groups))
|
||||
|
BIN
day_1/main2
Executable file
BIN
day_1/main2
Executable file
Binary file not shown.
22
day_1/main2.py
Normal file
22
day_1/main2.py
Normal file
|
@ -0,0 +1,22 @@
|
|||
|
||||
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)
|
||||
|
Reference in a new issue