Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Rover golf
D,N,E,S,W,R,L,M=%w{NESW y+=1 x+=1 y-=1 x-=1 d+=1 d-=1 e.(D[d%4])}
r=->(x,y,d,s){e=->(a){eval eval(a)};s.scan(/./){|a|e.(a)};[x,y,D[d%4]]}
p r.(1,2,D.index('N'),"LMLMLMLMM")
p r.(3,3,D.index('E'),"MMRMMRMRRM")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment