Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Straightforward solution in Clear category for Ground for the House by martin_b
def house(plan):
plan = plan.lstrip()
rowlen = plan.index('\n') + 1
top = plan.find('#') // rowlen
if top < 0:
return 0
bottom = plan.rfind('#') // rowlen + 1
rows = plan.split('\n')
left = min(p for p in (r.find('#') for r in rows) if p >= 0)
right = max(p for p in (r.rfind('#') + 1 for r in rows) if p > 0)
return (bottom - top) * (right - left)
Feb. 2, 2020
Comments: