Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Loops solution in Uncategorized category for Spaceship Landing Strip by contrebasse
def checkio(map):
map = [[area == 'G' or area == 'S' for area in line] for line in map]
width, height = len(map[0]), len(map)
maximum = 0
# Loop over starting point
for i in range(height):
for j in range(width):
if not map[i][j]:
continue
# Loop over size of area
for h in range(1, height - i + 1):
for w in range(1, width - j + 1):
if all(all(line[j:j+w]) for line in map[i:i+h]):
maximum = max(maximum, h * w)
else:
break
return maximum
if __name__ == '__main__':
assert checkio(['G']) == 1, 'First'
assert checkio(['GS','GS']) == 4, 'Second'
assert checkio(['GT','GG']) == 2, 'Third'
assert checkio(['GGTGG','TGGGG','GSSGT','GGGGT','GWGGG','RGTRT','RTGWT','WTWGR']) == 9, 'Fourth'
print('All is ok')
Oct. 26, 2012
Comments: