Skip to content

Instantly share code, notes, and snippets.

@meagar
Created July 18, 2018 17:54
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/d484eb4a1868b83513dac2c61bc5710d to your computer and use it in GitHub Desktop.
Save meagar/d484eb4a1868b83513dac2c61bc5710d 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
N = 20
last = ""
moves = N.times.map do
side = (SIDES - [last]).sample
turn = TURNS.sample
last = side
[side, turn].join
end
puts moves.join(", ") # F', B, F2, D2, U', R', D2, B2, L2, R2, U, L, U, L, U2, R2, D2, U, F', B'
@vaibhavatul47
Copy link

Shouldn't N be equal to 18? SIDES * TURNS

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment