43 lines
913 B
Python
43 lines
913 B
Python
data = []
|
|
for line in open("input"):
|
|
data.append(list(map(int, line.strip())))
|
|
|
|
visible = [[0]*len(x) for x in data]
|
|
|
|
for i in range(len(data)):
|
|
h = -1
|
|
for j in range(len(data[i])):
|
|
if data[i][j] > h:
|
|
visible[i][j] = 1
|
|
h = data[i][j]
|
|
if h == 9:
|
|
break
|
|
|
|
h = -1
|
|
for j in reversed(range(len(data[i]))):
|
|
if data[i][j] > h:
|
|
visible[i][j] = 1
|
|
h = data[i][j]
|
|
if h == 9:
|
|
break
|
|
|
|
for j in range(len(data[0])):
|
|
h = -1
|
|
for i in range(len(data)):
|
|
if data[i][j] > h:
|
|
visible[i][j] = 1
|
|
h = data[i][j]
|
|
if h == 9:
|
|
break
|
|
|
|
h = -1
|
|
for i in reversed(range(len(data))):
|
|
if data[i][j] > h:
|
|
visible[i][j] = 1
|
|
h = data[i][j]
|
|
if h == 9:
|
|
break
|
|
|
|
#print(visible)
|
|
print(sum(sum(x) for x in visible))
|