2022 day 1

This commit is contained in:
José Henrique Ivanchechen 2022-12-01 22:44:25 -03:00
parent d33dd531ea
commit 541851d7c6
2 changed files with 2268 additions and 0 deletions

2243
day1 Normal file

File diff suppressed because it is too large Load Diff

25
day1.py Normal file
View File

@ -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))