Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Record min&max solution in Clear category for Ground for the House by nakanohito_piyo
def house(plan):
plan = plan.split("\n")
plan = [x for x in plan if len(x)>0]
min_i = 9999
max_i = 0
min_j = 9999
max_j = 0
for i in range(len(plan)):
for j in range(len(plan[0])):
if plan[i][j] == "#":
min_i = min(i, min_i)
max_i = max(i, max_i)
min_j = min(j, min_j)
max_j = max(j, max_j)
if min_i == 9999:
return 0
else:
return (max_i-min_i+1)*(max_j-min_j+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
print("Coding complete? Click 'Check' to earn cool rewards!")
Dec. 19, 2018
Comments: