parent
2bbef2d9e9
commit
6fcf272b78
1 changed files with 27 additions and 0 deletions
@ -0,0 +1,27 @@ |
||||
matrix = [[int(i) for i in j] for j in open("input2.txt", 'r').read().splitlines()] |
||||
visible = set() |
||||
|
||||
def walk(line): |
||||
length = len(line) |
||||
vis = [0, length-1] |
||||
tallest = line[0] |
||||
tallestInv = line[-1] |
||||
for i in range(1, length): |
||||
if line[i] > tallest: |
||||
vis.append(i) |
||||
tallest = line[i] |
||||
if line[length-i] > tallestInv: |
||||
vis.append(length-i) |
||||
tallestInv = line[-i] |
||||
print(vis) |
||||
return vis |
||||
|
||||
for i in range(len(matrix)): |
||||
for coord in walk(matrix[i]): |
||||
visible.add((i, coord)) |
||||
for i in range(len(matrix[0])): |
||||
for coord in walk([matrix[j][i] for j in range(len(matrix[0]))]): |
||||
visible.add((coord, i)) |
||||
|
||||
print(visible) |
||||
print(len(visible)) |
Loading…
Reference in new issue