Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
trim top/bottom and transpose solution in Clear category for Ground for the House by tokyoamado
from typing import List
from itertools import dropwhile
all0 = lambda x: '#' not in x
def trim_tb(plan: List[str]) -> List[str]:
trim_t = list(dropwhile(all0, plan))
trim_b = list(dropwhile(all0, reversed(trim_t)))
return reversed(trim_b)
def house(plan):
lplan = filter(None, plan.split('\n'))
tr1 = trim_tb(lplan)
tr2 = list(trim_tb(zip(*tr1)))
s = len(tr2)
return s * len(tr2[0]) if s else 0
Sept. 28, 2018