You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
509 B
22 lines
509 B
2 years ago
|
lines = [ [int(j) for j in list(i)] for i in open("input.txt", 'r').read().splitlines()]
|
||
|
|
||
|
summa = 0
|
||
|
lowList = []
|
||
|
for x in range(len(lines)):
|
||
|
for y in range(len(lines[x])):
|
||
|
v = lines[x][y]
|
||
|
l = 9 if x == 0 else lines[x-1][y]
|
||
|
r = 9 if x == len(lines)-1 else lines[x+1][y]
|
||
|
u = 9 if y == 0 else lines[x][y-1]
|
||
|
d = 9 if y == len(lines[x])-1 else lines[x][y+1]
|
||
|
if v < l and v < r and v < u and v < d:
|
||
|
summa += 1 + v
|
||
|
lowList.append((x,y))
|
||
|
|
||
|
for p in lowList:
|
||
|
size = 0
|
||
|
|
||
|
|
||
|
print(summa)
|
||
|
print(lowList)
|