2022 day 1
This commit is contained in:
parent
d33dd531ea
commit
541851d7c6
|
@ -0,0 +1,25 @@
|
||||||
|
import os
|
||||||
|
|
||||||
|
cals = []
|
||||||
|
with open("day1", 'r') as file:
|
||||||
|
cals = file.read().split('\n')
|
||||||
|
|
||||||
|
number = 3
|
||||||
|
max_cals = [0 for i in range(number)]
|
||||||
|
max_cals_i = [0 for i in range(number)]
|
||||||
|
|
||||||
|
current_cals = 0
|
||||||
|
for i, cal in enumerate(cals):
|
||||||
|
if cal == '':
|
||||||
|
min_cal = min(max_cals)
|
||||||
|
if current_cals > min_cal:
|
||||||
|
max_cals_i[max_cals.index(min_cal)] = i
|
||||||
|
max_cals[max_cals.index(min_cal)] = current_cals
|
||||||
|
current_cals = 0
|
||||||
|
continue
|
||||||
|
|
||||||
|
current_cals += int(cal)
|
||||||
|
|
||||||
|
print(sum(max_cals))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue