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 tokiojapan55
def house(plan):
row_min = col_min = len(plan)
row_max = col_max = -1
for row, line in enumerate(plan.splitlines()):
for col, letter in enumerate(line):
if letter == '#':
col_min, col_max = min(col, col_min), max(col, col_max)
row_min, row_max = min(row, row_min), max(row, row_max)
return 0 if row_max == -1 else (row_max - row_min + 1) * (col_max - col_min + 1)
June 18, 2021