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 Piotr16
def house(plan):
p = plan.split()
tym = -1
w = 0
h = 0
n = -1
while p[n].find('#') < 0:
p.remove(p[n])
if len(p) == 0:
return 0
n = 0
while p[n].find('#') < 0:
p.remove(p[n])
if len(p) == 0:
return 0
i = 0
while i < len(p):
if p[i].find('#') >= 0:
l = p[i].find('#')
r = p[i].rfind('#')
if (l == r) and l != tym:
w += 1
elif r - l + 1 > w:
w = r - l + 1
tym = l
h += 1
i += 1
return h * w
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
print("Coding complete? Click 'Check' to earn cool rewards!")
Oct. 12, 2018