Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Building Visibility by tom-tom
def checkio(buildings):
landscape = [0] * 12
def is_visible(building):
x1, _, x2, _, z = building
result = any(height < z for height in landscape[x1 : x2])
landscape[x1 : x2] = [max(height, z) for height in landscape[x1 : x2]]
return result
return sum(is_visible(building) for building in sorted(buildings, key=lambda b: b[1]))
Aug. 7, 2017