1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
x=y=0 d=2 gets.chars.each{|c| case c when ?R d=(d-1)%4 when ?L d=(d+1)%4 when ?B d=(d+(d%2)*2)%4 y=9-y else e=(d/2*2-1)*c.to_i xt=x x=(x+e*((d+1)%2))%32 y=(y+e*(d%2)+((xt-x).abs>9?5:0))%10 end } puts [x+1,(y<5?y+97:65+y%5).chr]*""
You can clone a snippet to your computer for local editing. Learn more.