Ejection by kaki(bk1e)

d=[];r=[];u=[]
$<.map{|l|l.chomp!
z=l.size
z.times{|i|[[d,?D],[u,?U]].map{|a,b|l[i]==b&&(e=a.find{|c|l[i]!=c[i]}
e||=(a<<" "*z)[-1]
e[i]=l[i])}}
r<<l.tr("DRU"," ")+l.tr("^R","")}
puts (u.reverse+r+d).map &:rstrip

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

download

return top