-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDay1.py
More file actions
33 lines (30 loc) · 829 Bytes
/
Day1.py
File metadata and controls
33 lines (30 loc) · 829 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
def depths(): # increasing depths
f = open("input day 1.txt", "r")
lines = f.readlines()
i = 1
depths = []
increasing = 0
for line in lines:
depths.append(int(line))
while(i < len(lines)):
if(depths[i] > depths[i - 1]):
increasing += 1
i += 1
print(increasing)
print("done")
def windowdepths(): # depth measurement window
f = open("input day 1.txt", "r")
lines = f.readlines()
i = 1
depths = []
increasing = 0
for line in lines:
depths.append(int(line))
while (i < len(lines) - 2):
current = depths[i] + depths[i + 1] + depths[i + 2]
prevdepth = depths[i - 1] + depths[i] + depths[i + 1]
if current > prevdepth:
increasing += 1
i += 1
print(increasing)
print("done")