class RubiksCube::Solution

Abstract interface for a RubiksCube solution

Must implement:

solution: array or string of moves necessary to solve the cube
pretty:   human readable string of solution

Attributes

cube[R]

Public Class Methods

new(cube) click to toggle source
# File lib/rubiks_cube/solution.rb, line 20
def initialize(cube)
  @cube = Cube.new(cube.state)
end

Public Instance Methods

length() click to toggle source
# File lib/rubiks_cube/solution.rb, line 32
def length
  Array(solution).flatten.join(' ').split.count
end
pretty() click to toggle source

Human readable string of solution

# File lib/rubiks_cube/solution.rb, line 16
def pretty
  raise "#pretty unimplemented in #{self.class.name}"
end
solution() click to toggle source

Array or String of moves necessary to solve the cube

# File lib/rubiks_cube/solution.rb, line 11
def solution
  raise "#solution unimplemented in #{self.class.name}"
end
solved?() click to toggle source
# File lib/rubiks_cube/solution.rb, line 28
def solved?
  cube.solved?
end
state() click to toggle source
# File lib/rubiks_cube/solution.rb, line 24
def state
  cube.state
end