aoc2022/d08/part1.py

20 lines
442 B
Python
Raw 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)
N = 0
Q = 0
2022-12-08 11:44:02 +00:00
for i in range(H):
for j in range(W):
v = L[i][j]
# look right
r = all(L[i][k]<v for k in range(j+1, W))
# look left
l = all(L[i][k]<v for k in range(j))
# look up
u = all(L[k][j]<v for k in range(i))
# look down
d = all(L[k][j]<v for k in range(i+1,H))
N += (r|l|u|d)
Q += W + H
print(N, W*H*(W+H), Q)