Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
lists solution in Clear category for Ground for the House by maksimus
def house(plan):
l = plan.strip().split("\n")
l_rev = [''.join(f) for f in list(zip(*l[::-1]))]
la = [i for i in range(len(l)) if '#' in l[i]]
lb = [j for j in range(len(l_rev)) if '#' in l_rev[j]]
if la and lb:
a = max(la)-min(la)+1
b = max(lb)-min(lb)+1
return a*b
else:
return 0
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!")
Aug. 17, 2019
Comments: