Skip to content

Commit 67b63a3

Browse files
committed
Add 2022 day 1 challenge
1 parent 3cc684c commit 67b63a3

File tree

2 files changed

+2291
-0
lines changed

2 files changed

+2291
-0
lines changed

2022/1/day1.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
from os import path
2+
3+
__location__ = path.dirname(__file__)
4+
5+
with open(path.join(__location__, "input"), mode="r", encoding="utf-8") as input:
6+
cur_calorie_count = 0
7+
elfs = []
8+
for line in input:
9+
if line != "\n":
10+
cur_calorie_count += int(line)
11+
else:
12+
elfs.append(cur_calorie_count)
13+
14+
cur_calorie_count = 0
15+
16+
elfs.sort(reverse=True)
17+
18+
print("Most calories carried: " + str(elfs[0]))
19+
20+
top_three_sum = elfs[0] + elfs[1] + elfs[2]
21+
print("Sum of top three carrieres: " + str(top_three_sum))
22+

0 commit comments

Comments
 (0)