Skip to content

Instantly share code, notes, and snippets.

@meagar
Created July 18, 2018 17:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save meagar/5d45cffebefa563a8b3ca01e3abd9a4e to your computer and use it in GitHub Desktop.
Save meagar/5d45cffebefa563a8b3ca01e3abd9a4e to your computer and use it in GitHub Desktop.
SIDES = %w(R L B F U D)
TURNS = ["", "2", "'"] # one turn, two turns, one counter-turn
moves = 20.times.inject([]) { |memo, _| memo + [(SIDES - [memo.last]).sample] }
p moves.zip(TURNS.cycle).map(&:join) # ["F", "L2", "U'", "B", "L2", "R'", "D", "U2", "B'", "D", "F2", "U'", "L", "B2", "U'", "D", "R2", "L'", "D", "F2"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment