Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
occupied_area solution in Clear category for Ground for the House by Smerda
def house(plan):
found_blocks = [(num, pos) for num, line in enumerate(plan.strip().splitlines())
for pos, piece in enumerate(line) if piece == "#"]
if not found_blocks:
return 0
else:
height = (found_blocks[-1][0] - found_blocks[0][0]) + 1
positions = list(map(lambda x: x[1], found_blocks))
width = (max(positions) - min(positions)) + 1
return height * width
Sept. 25, 2018
Comments: