Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Uncategorized category for Building Visibility by natsuki
from collections import namedtuple
Building = namedtuple('Building', 'x1 y1 x2 y2 height')
def checkio(buildings):
bs = [Building(*b) for b in buildings]
result = set()
for x in range(min(b.x1 for b in bs), max(b.x2 for b in bs)):
height = 0
for b in sorted([b for b in bs if b.x1 <= x < b.x2], key=lambda b: b.y1):
if b.height > height:
result.add(b)
height = b.height
return len(result)
April 16, 2014
Comments: