adventofcode2022/day08/sol2.py

42 lines
900 B
Python
Raw Normal View History

2022-12-08 05:33:14 +00:00
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]
a = 0
2022-12-09 06:08:51 +00:00
i = ii
2022-12-08 05:33:14 +00:00
for j in range(jj+1, len(data[ii])):
a += 1
2022-12-09 06:08:51 +00:00
if data[i][j] >= top:
2022-12-08 05:33:14 +00:00
break
b = 0
for j in reversed(range(0, jj)):
b += 1
2022-12-09 06:08:51 +00:00
if data[i][j] >= top:
2022-12-08 05:33:14 +00:00
break
2022-12-09 06:08:51 +00:00
j = jj
2022-12-08 05:33:14 +00:00
c = 0
for i in range(ii+1, len(data)):
c += 1
2022-12-09 06:08:51 +00:00
if data[i][j] >= top:
2022-12-08 05:33:14 +00:00
break
d = 0
for i in reversed(range(0, ii)):
d += 1
2022-12-09 06:08:51 +00:00
if data[i][j] >= top:
2022-12-08 05:33:14 +00:00
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))