blob: 7ad0cf7220229900dab1dfc60361c8e4a0aaa9c2 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
data = [[int(calory) for calory in block.split("\n") if calory != ''] for block in open("input").read().split("\n\n")]
# i don't know list comprehension
def part1():
res = 0
for block in data:
s = sum(block)
if s > res:
res = s
return res
def part2():
top3 = [0,0,0]
for block in data:
s = sum(block)
m = min(top3)
if s > m:
top3.remove(m)
top3.append(s)
return sum(top3)
print(f"Part 1: {part1()}")
print(f"Part 2: {part2()}")
|