feat: day1 puzzle complete

This commit is contained in:
2022-12-01 14:51:49 -05:00
parent 3fb4b94232
commit 9e4c19567a
2 changed files with 2281 additions and 0 deletions

2248
day1/input.txt Normal file

File diff suppressed because it is too large Load Diff

33
day1/main.py Normal file
View File

@@ -0,0 +1,33 @@
import string
elves = [[]]
input_file = open("input.txt", "r")
lines = input_file.readlines()
for line in lines:
if not line.isspace():
elves[-1].append(int(line))
else:
elves.append([])
# part 1
max_calories = -1
for elf in elves:
calories = sum(elf)
if calories > max_calories:
max_calories = calories
print(max_calories)
# part 2
calories_list = []
for elf in elves:
calories = sum(elf)
calories_list.append(calories)
calories_list.sort()
print(sum(calories_list[-3:]))