Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Ground for the House by Oleg_Domokeev
def house(plan):
plan_list = plan.split()
left, right, top, bottom = None, None, None, None
for i in range(len(plan_list)):
if '#' in plan_list[i]:
bottom = i
if top == None:
top = i
if left == None or left > plan_list[i].find('#'):
left = plan_list[i].find('#')
if right == None or right < plan_list[i].rfind('#'):
right = plan_list[i].rfind('#')
if top == None:
return 0
return (bottom - top + 1) * (right - left + 1)
Sept. 4, 2018