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 frbrgeorge
def house(plan):
#replace this for solution
plan = plan.strip()+'\n'
w = plan.find('\n')+1
p = [i for i,v in enumerate(plan) if v == "#"]
if not p: return 0
return (max(e%w for e in p)-min(e%w for e in p)+1)*(p[-1]//w-p[0]//w+1)
if __name__ == '__main__':
print("Example:")
print(house('''
0000000
##00##0
######0
##00##0
#0000#0
'''))
#These "asserts" using only for self-checking and not necessary for auto-testing
assert house('''
0000000
##00##0
######0
##00##0
#0000#0
''') == 24
assert house('''0000000000
#000##000#
##########
##000000##
0000000000
''') == 30
assert house('''0000
0000
#000
''') == 1
assert house('''0000
0000
''') == 0
assert house('''
0##0
0000
#00#
''') == 12
assert house('''0##0''') == 2
print("Coding complete? Click 'Check' to earn cool rewards!")
Dec. 20, 2018