(update) 2022 day 01

This commit is contained in:
2025-12-24 11:49:06 +01:00
parent 6e48b42abf
commit e2c7526fed
3 changed files with 2270 additions and 0 deletions

14
2022/01/example Normal file
View File

@ -0,0 +1,14 @@
1000
2000
3000
4000
5000
6000
7000
8000
9000
10000

2235
2022/01/input Normal file

File diff suppressed because it is too large Load Diff

21
2022/01/main.py Normal file
View File

@ -0,0 +1,21 @@
with open("input") as file:
cal: list = []
elf = 1
calories = 0
for line in file.readlines():
if line.strip() == "":
cal.append((elf, calories))
elf += 1
calories = 0
continue
calories += int(line.strip())
cal.sort(key=lambda x: -x[1])
print("part1:", cal[0])
print("part2:", sum(list(map(lambda x: x[1], cal[:3]))))