Class: Scrambler::RandomState::TwoByTwo
- Inherits:
-
Object
- Object
- Scrambler::RandomState::TwoByTwo
- Defined in:
- lib/scrambler/random_state/two_by_two.rb
Instance Method Summary collapse
-
#initialize ⇒ TwoByTwo
constructor
A new instance of TwoByTwo.
- #scramble ⇒ Object
Constructor Details
Instance Method Details
#scramble ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/scrambler/random_state/two_by_two.rb', line 12 def scramble permutation = Solver::SOLVED_PERMUTATION.shuffle orientation = Array.new(6) { rand 3 } orientation += [(3 - (orientation.inject { |sum, i| sum + i } % 3)) % 3] # fix orientation parity @solver.solve(CornerPermutation.new(permutation), CornerOrientation.new(orientation)) end |