Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Top, bottom, left and right solution in Clear category for Ground for the House by Ilis
def house(plan):
if "#" not in plan:
return 0
h1 = plan.split()
while "#" not in h1[0]:
del h1[0]
while "#" not in h1[-1]:
del h1[-1]
la = min([line.find("#") for line in h1 if "#" in line])
lb = max([line.rfind("#") for line in h1 if "#" in line])
h1 = [line[la:lb + 1] for line in h1]
return len(h1) * len(h1[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!")
April 4, 2019