Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Done solution in Clear category for Ground for the House by nikita.dzhigir
def house(plan):
strings = [i for i in plan.split('\n') if i != '']
horizontal = sorted(list({j for i in strings for j, v in enumerate(i) if v == '#'}))
width = horizontal[-1] - horizontal[0] + 1 if horizontal else 0
vertical = [i for i, v in enumerate(strings) if v.find('#') != -1]
height = vertical[-1] - vertical[0] + 1 if vertical else 0
return width * height
if __name__ == '__main__':
#These "asserts" using only for self-checking and not necessary for auto-testing
assert house('''0000000000\n0000000000\n0000000000\n0000000000\n0000000000\n''') == 24
print("Coding complete? Click 'Check' to earn cool rewards!")
Oct. 12, 2018
Comments: