started advent of code 2021

This commit is contained in:
Dmitry Fedotov
2021-12-04 16:27:56 +03:00
parent 49d5a07d58
commit 31e47c9521
5 changed files with 2067 additions and 0 deletions

21
day1_2.py Executable file
View File

@@ -0,0 +1,21 @@
#!/usr/bin/env python3
import sys, utils
def find_increasing_window(l: list):
win = l[:3]
count = 0
for n in range(3, len(l)):
new_win = [l[n-2], l[n-1], l[n]]
if sum(new_win) > sum(win):
count += 1
win = new_win
return count
if __name__ == '__main__':
if len(sys.argv) < 2:
print("please supply input file")
sys.exit()
f = utils.File(sys.argv[1])
print(find_increasing_window(f.get_ints()))