straight line floodfill by niisaka

import os
m=os.read(0,1e5)
w=m.find('\n')+1
t=(w,1,-w,-1)
s=zip([m.find('.')]*4,t)
while s:
 x,d=s.pop()
 while'#'>m[x+d]:x+=d;m=m[:x]+'.'+m[x+1:];s+=zip([x]*4*('#'==m[x+d]),t)
print m

Note that non-ascii characters in the above source code will be escaped (such as \x9f).

download

return to the top page