-
Notifications
You must be signed in to change notification settings - Fork 0
/
Day9puzzle1.py
51 lines (43 loc) · 1.35 KB
/
Day9puzzle1.py
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
data = open("E:\CodingStuff\AdventOfCode\Day9imput.txt")
data = data.readlines()
for row in range(len(data)):
data[row] = data[row].strip("\n")
data = [list(x) for x in data]
data = [[int(c) for c in x] for x in data]
potentialvalues = []
#finding points smaller than those above them
for col in range(len(data)):
for row in range(len(data[0])):
if (col!=0):
if(data[col][row]<data[col-1][row]):
potentialvalues.append([col,row])
else:
potentialvalues.append([col,row])
print(potentialvalues)
cheese = []
#finding points smaller than those below them
for point in potentialvalues:
if(point[0]<len(data)-1):
if(data[point[0]][point[1]]>=data[point[0]+1][point[1]]):
cheese.append(point)
for point in cheese:
potentialvalues.remove(point)
cheese = []
for point in potentialvalues:
if(point[1]!=0):
if(data[point[0]][point[1]]>=data[point[0]][point[1]-1]):
cheese.append(point)
for point in cheese:
potentialvalues.remove(point)
cheese = []
for point in potentialvalues:
if(point[1]<len(data[0])-1):
if(data[point[0]][point[1]]>=data[point[0]][point[1]+1]):
cheese.append(point)
for point in cheese:
potentialvalues.remove(point)
#finding the danger
sum=0
for point in potentialvalues:
sum+=data[point[0]][point[1]]+1
print(sum)