Solve day one

This commit is contained in:
Thom Dickson 2021-12-03 17:13:22 -05:00
parent 9e5c0a48de
commit 6ae040193e
Signed by: boots
GPG Key ID: 40BE2AF8EBF8D2BB
2 changed files with 2022 additions and 0 deletions

2000
day01.in Normal file

File diff suppressed because it is too large Load Diff

22
day01.py Normal file
View File

@ -0,0 +1,22 @@
def calc_inc(x):
prev = 0
count = 0
for i in x:
if i > prev and prev != 0:
count += 1
prev = i
return count
with open("day01.in", "r") as f:
fa = [int(i.rstrip()) for i in f]
count_a = calc_inc(fa)
win = []
for i in range(len(fa)):
if i + 2 < len(fa):
win.append(sum(fa[i:i+3]))
count_b = calc_inc(win)
print("Increased", count_a, "times")
print("Increased", count_b, "times")