2022-12-17 01:16:18 +01:00
|
|
|
import sys
|
|
|
|
|
|
|
|
def isVisible(lines, row, col):
|
|
|
|
scenic = 1
|
2022-12-17 01:58:22 +01:00
|
|
|
|
|
|
|
# up
|
2022-12-17 01:16:18 +01:00
|
|
|
score1 = 0
|
2022-12-17 01:58:22 +01:00
|
|
|
for x in lines[:row][::-1]:
|
2022-12-17 01:16:18 +01:00
|
|
|
score1 += 1
|
|
|
|
if ( x[col] >= lines[row][col]):
|
|
|
|
break
|
2022-12-17 01:58:22 +01:00
|
|
|
scenic *= score1
|
2022-12-17 01:16:18 +01:00
|
|
|
|
2022-12-17 01:58:22 +01:00
|
|
|
# left
|
2022-12-17 01:16:18 +01:00
|
|
|
score3 = 0
|
2022-12-17 01:58:22 +01:00
|
|
|
for x in lines[row][:col-1][::-1]:
|
|
|
|
score3 += 1
|
2022-12-17 01:16:18 +01:00
|
|
|
if ( x >= lines[row][col]):
|
|
|
|
break
|
|
|
|
scenic *= score3
|
|
|
|
|
2022-12-17 01:58:22 +01:00
|
|
|
# right
|
2022-12-17 01:16:18 +01:00
|
|
|
score4 = 0
|
2022-12-17 01:58:22 +01:00
|
|
|
for x in lines[row][col+1:]:
|
|
|
|
score4 += 1
|
2022-12-17 01:16:18 +01:00
|
|
|
if ( x >= lines[row][col]):
|
|
|
|
break
|
|
|
|
scenic *= score4
|
|
|
|
|
2022-12-17 01:58:22 +01:00
|
|
|
# down
|
|
|
|
score2 = 0
|
|
|
|
for x in lines[row:]:
|
|
|
|
score2 += 1
|
|
|
|
if ( x[col] >= lines[row][col]):
|
|
|
|
break
|
|
|
|
scenic *= score2
|
|
|
|
|
|
|
|
|
|
|
|
print(row, col, "|", score1, score2, score3, score4, "|", scenic)
|
2022-12-17 01:16:18 +01:00
|
|
|
return scenic
|
|
|
|
|
|
|
|
with open(sys.argv[1], "r") as file:
|
|
|
|
lines = file.readlines()
|
|
|
|
for a in range(len(lines)):
|
|
|
|
lines[a] = lines[a].rstrip()
|
|
|
|
# a = a.rstrip()
|
|
|
|
|
|
|
|
best=0
|
|
|
|
for row in range(len(lines)):
|
|
|
|
for col in range(len(lines[0])):
|
|
|
|
# print(lines[row][col], end="")
|
|
|
|
yes = isVisible(lines, row, col)
|
|
|
|
best = max(best, yes)
|
|
|
|
|
|
|
|
print(best)
|