added day01

This commit is contained in:
Peter Hudec
2021-12-02 05:55:21 +01:00
parent b884754d87
commit e80b51f95e
6 changed files with 4035 additions and 0 deletions

19
01/solve02.py Normal file
View File

@ -0,0 +1,19 @@
#!/usr/bin/env python
window = []
inc = 0
with open("input02.txt", "r") as f:
for line in f:
num = int(line)
window.append(num)
if len(window) < 4:
continue
x1 = sum(window[0:3])
x2 = sum(window[1:4])
if x1 < x2:
inc += 1
window.pop(0)
print(inc)