Class: Scrambler::Megaminx

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

Instance Method Summary collapse

Instance Method Details

#scramble(lines = 7, columns = 10) ⇒ Object



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

def scramble(lines = 7, columns = 10)
  turns = %w(R D)
  variants = %w(-- ++)
  variants_for_u = ["'", ""]
  (1..lines).map do |line|
    ((0..(columns-1)).map do |column|
      turns[column % 2] + variants.sample
    end + ["U#{variants_for_u.sample}"]).join(" ")
  end.join("\n")
end