Puyo Puyo by yvl

s=gets p
(x=""+s).gsub(/\w/){a=[i=j=$`.size]
c=proc{$&==x[j,1]&&([j-1,j+1,j-9,j+9].-a<<j).map{|j|c[]}}
c[]
a[4]&&(s[i]=s[i-=9]while i>9;s[i]=32)}while x!=s&&$.-=1
puts s,"#{-$.} chains"

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

download

return to the top page