Interface to several Rubik’s cube solvers.

The first is by Michael Reid, and tries to find an optimal solution given the cube’s state, and may take a long time. See http://www.math.ucf.edu/~reid/Rubik/optimal_solver.html

The second is by Eric Dietz, and uses a standard (?) algorithm to solve the cube one level at a time. It is extremely fast, but often returns a far from optimal solution. See http://wrongway.org/?rubiksource

The third is by Dik Winter and implements Kociemba’s algorithm which finds reasonable solutions relatively quickly, and if it is kept running will eventually find the optimal solution.

AUTHOR:
– Optimal was written by Michael Reid <reid@math.ucf.edu> (2004) – Cubex was written by Eric Dietz <root@wrongway.org> (2003) – Kociemba was written by Dik T. Winter <dik.winter@cwi.nl> (1993) – Initial interface by Robert Bradshaw (2007-08)
class sage.interfaces.rubik.CubexSolver
format_cube(facets)
solve(facets)

EXAMPLES:

sage: from sage.interfaces.rubik import *
sage: C = RubiksCube("R U")
sage: CubexSolver().solve(C.facets())
'R U'
sage: C = RubiksCube("R U F L B D")
sage: sol = CubexSolver().solve(C.facets()); sol
"U' L' L' U L U' L U D L L D' L' D L' D' L D L' U' L D' L' U L' B' U' L' U B L D L D' U' L' U L B L B' L' U L U' L' F' L' F L' F L F' L' D' L' D D L D' B L B' L B' L B F' L F F B' L F' B D' D' L D B' B' L' D' B U' U' L' B' D' F' F' L D F'"
sage: RubiksCube(sol) == C
True
sage: C = RubiksCube("R2 F'")
sage: CubexSolver().solve(C.facets())
"R' R' F'"
sage: C = RubiksCube().scramble()
sage: sol = CubexSolver().solve(C.facets())
sage: C == RubiksCube(sol)
True
class sage.interfaces.rubik.DikSolver
format_cube(facets)
solve(facets, timeout=10, extra_time=2)

EXAMPLES:

sage: from sage.interfaces.rubik import *
sage: C = RubiksCube().move("R U")
sage: DikSolver().solve(C.facets())
'R U'
sage: C = RubiksCube().move("R U F L B D")
sage: DikSolver().solve(C.facets())
'R U F L B D'
sage: C = RubiksCube().move("R2 F'")
sage: DikSolver().solve(C.facets())
"R2 F'"
class sage.interfaces.rubik.OptimalSolver(verbose=False, wait=True)

Interface to Michael Reid’s optimal Rubik’s Cube solver.

format_cube(facets)
ready()
solve(facets)

The initial startup and precomputation are substantial…

TODO: Let it keep searching once it found a solution?

EXAMPLES:

sage: from sage.interfaces.rubik import *
sage: solver = DikSolver()
sage: solver = OptimalSolver()  # long time (28s on sage.math, 2012)
Initializing tables...
Done.
sage: C = RubiksCube("R U")
sage: solver.solve(C.facets())
'R  U'
sage: C = RubiksCube("R U F L B D")
sage: solver.solve(C.facets())
'R  U  F  L  B  D'
sage: C = RubiksCube("R2 D2")
sage: solver.solve(C.facets())
'R2 D2'
start()
stop()
class sage.interfaces.rubik.SingNot(s)

This class is to resolve difference between various Singmaster notation. Case is ignored, and the second and third letters may be swapped.

EXAMPLES:

sage: from sage.interfaces.rubik import SingNot
sage: SingNot("acb") == SingNot("ACB")
True
sage: SingNot("acb") == SingNot("bca")
False