adventofcode2022/day08/sol2b.py

30 lines
724 B
Python

data = []
for line in open("input"):
data.append(list(map(int, line.strip())))
def count(top, ii, jj):
n = 0
for i in ii:
for j in jj:
n += 1
if data[i][j] >= top:
return n
return n
scores = []
for ii in range(len(data)):
for jj in range(len(data[ii])):
top = data[ii][jj]
a = count(top, [ii], range(jj+1, len(data[ii])))
b = count(top, [ii], reversed(range(0, jj)))
c = count(top, range(ii+1, len(data)), [jj])
d = count(top, reversed(range(0, ii)), [jj])
#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))