Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
4-liner: no floodfill solution in Creative category for Calculate Islands by przemyslaw.daniel
def checkio(t,p=__import__('itertools').permutations,r=range,l=len,c=complex):
v={c(x,y):{c(x,y)}for x in r(l(t))for y in r(l(t[0]))if t[x][y]}
for a,b in[(a,b)for a,b in p(v,2)if abs(a-b)<2]*9:v[a]|=v[b];v[b]!=v[a]
return sorted([l(x)for x in{frozenset(y)for y in v.values()}])
July 29, 2017
Comments: