adventofcode2022/day08/sol2.py

48 lines
1006 B
Python

data = []
for line in open("input"):
data.append(list(map(int, line.strip())))
scores = []
for ii in range(len(data)):
for jj in range(len(data[ii])):
top = data[ii][jj]
h = -1
a = 0
for j in range(jj+1, len(data[ii])):
a += 1
h = data[ii][j]
if h >= top:
break
b = 0
h = -1
for j in reversed(range(0, jj)):
b += 1
h = data[ii][j]
if h >= top:
break
c = 0
h = -1
for i in range(ii+1, len(data)):
c += 1
h = data[i][jj]
if h >= top:
break
d = 0
h = -1
for i in reversed(range(0, ii)):
d += 1
h = data[i][jj]
if h >= top:
break
print(ii,jj,a,b,c,d)
score = a*b*c*d
scores.append(score)
#print(visible)
#print(sum(sum(x) for x in visible))
print(max(scores))