Uncheated

This commit is contained in:
Thomas Muller 2022-12-02 20:13:46 -05:00
parent 6a3d307033
commit f8d4de16f6
Signed by: thomas
GPG key ID: AF006EB730564952
3 changed files with 37 additions and 0 deletions

15
day_1/main.py Normal file
View 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

Binary file not shown.

22
day_1/main2.py Normal file
View 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)