Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
numpy solution in 3rd party category for Building Visibility by gyahun_dash
from numpy import fmax, unique, vstack, zeros
def checkio(buildings, size=(12, 12)):
indices, altitudes = zeros(size), zeros(size)
for index, (west, south, east, north, height) in enumerate(buildings, 1):
indices[south:north, west:east] = index
altitudes[south:north, west:east] = height
maxalts = fmax.accumulate(altitudes)
observed = vstack([maxalts[0] > 0, maxalts[:-1] < maxalts[1:]])
return unique(indices[observed]).size
Dec. 28, 2016
Comments: