straight line floodfill SIMPLIFIED by clock

#!ruby -p0
a="(#{w=".{#{~/$/}}"}[^#])*#{w}"
b="#{w}([^#]#{w})*"
20.times{sub /(\#) ([^#]*\.)/,c='\1.\2'
sub /(\.[^#]*) (\#)/,c
sub /(\##{w}) (#{a}\.)/m,c
sub /(\.#{b}) (#{w}\#)/m,'\1.\3'}
?z.times{sub /(\.[^#]*) ([^#]*\.)/,'\1*\2'
sub /(\.#{a}) (#{b}\.)/m,'\1*\3'}
gsub"*","."

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

download

return to the top page