27 lines
749 B
Python
27 lines
749 B
Python
#!/usr/bin/env python3
|
|
import math
|
|
from itertools import count, takewhile
|
|
|
|
import numpy as np
|
|
|
|
forest = np.array([np.array(list(map(int, x.strip()))) for x in open("input.txt")])
|
|
|
|
max_score = 0
|
|
for y in range(len(forest)):
|
|
for x in range(len(forest[0])):
|
|
score = 1
|
|
for dir in np.array([(0, -1), (0, 1), (-1, 0), (1, 0)]):
|
|
pos = np.array([y, x]) + dir
|
|
dir_score = 0
|
|
for i in takewhile(lambda _: np.all(pos >= 0) and np.all(pos < forest.shape), count()):
|
|
dir_score += 1
|
|
if forest[tuple(pos)] >= forest[y, x]:
|
|
break
|
|
pos += dir
|
|
score *= dir_score
|
|
max_score = max(max_score, score)
|
|
print(max_score)
|
|
|
|
|
|
|