straight line floodfill SIMPLIFIED by leonid

#!ruby -p0
$$.times{|i|$_[i%=~/\z/]==?.&&[1,e=1+~/$/].map{|d|j=i
1while$_[j+=d]!=?#
$_[j]=?.while$_[j-=d]!=?#if$_[i-e]*$_[i+e]%?#<1
e=d}}

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

download

return top