aoc2022/d08/part2.py

34 lines
535 B
Python
Raw Permalink Normal View History

2022-12-08 11:44:02 +00:00
import sys
L = list(list(map(int,s)) for s in sys.stdin.read().splitlines())
W = len(L[0]) ; H = len(L)
S=0
for i in range(H):
for j in range(W):
v = L[i][j]
# look right
r = 0
for k in range(j+1, W):
r += 1
if L[i][k]>=v:
break
# look left
l = 0
for k in range(j-1,-1,-1):
l+=1
if L[i][k]>=v:
break
# look up
u = 0
for k in range(i-1,-1,-1):
u+=1
if L[k][j]>=v:
break
# look down
d = 0
for k in range(i+1,H):
d += 1
if L[k][j]>=v:
break
S = max(S,r*l*u*d)
print(S)