Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Floodfill solution in Clear category for Calculate Islands by veky
def checkio(data):
col,result=len(data[0]),[]
while True:
size=0
try: queue={divmod(sum(data,[]).index(1),col)}
except ValueError: return sorted(result)
while queue:
i,j=queue.pop()
data[i][j]=0
size+=1
queue|={(i+di,j+dj) for di in (-1,0,1) if 0<=i+di
June 19, 2013
Comments: