Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Numpy slices and namedtuple solution in 3rd party category for Building Visibility by rodka81
import numpy as np
from collections import namedtuple
Building = namedtuple('Building', 'w s e n h')
def checkio(buildings):
buildings = [Building(*b) for b in buildings]
m = np.zeros((max(b.e for b in buildings),
max(b.n for b in buildings)))
for b in buildings:
m[b.w:b.e, b.s:b.n] = b.h
return sum(any(np.all(m[j, :b.s] < b.h) for j in range(b.w, b.e))
for b in buildings)
Feb. 18, 2019
Comments: