Class: Scrambler::Cube

Inherits:
Object
  • Object
show all
Defined in:
lib/scrambler/cube.rb

Instance Method Summary collapse

Instance Method Details

#scramble(turns, length) ⇒ Object



3
4
5
6
7
8
9
10
# File 'lib/scrambler/cube.rb', line 3

def scramble(turns, length)
  variants = ['', "'", '2']
  axis = rand turns.size
  (1..length).map do
    axis = (axis + rand(turns.size - 1) + 1) % turns.size
    turns[axis].sample + variants.sample
  end.join(' ')
end