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 rafal.pawlowski
def house(plan):
lst = [list(el) for el in plan.split('\n') if el != '']
rot_lst = [list(reversed(x)) for x in zip(*lst)]
print(rot_lst)
lenth = len(lst[0])
lenth1 = len(rot_lst[0])
print(lst)
hight = 0
wide = 0
row_min = []
row_max = []
col_min = []
col_max = []
for row in lst:
if '#' in row:
a = row.index('#')
row_min.append(a)
b = lenth - row[::-1].index('#')
row_max.append(b)
for column in rot_lst:
if '#' in column:
c = column.index('#')
col_min.append(c)
d = lenth1 - column[::-1].index('#')
col_max.append(d)
print(row_max)
print(row_min)
print(col_max)
print(col_min)
if row_min and col_min:
return (max(row_max) - min(row_min)) * (max(col_max) - min(col_min))
else:
return 0
print(house("\n0000##000#\n0000######\n00000000##\n0000#####0\n"))
Feb. 18, 2019
Comments: