Here you can find two equivalent implementations (in C and Python) of Herbert Kociemba's two-phase algorithm for solving Rubik's Cube. Original Java implementation can be found here: http://kociemba.org/download.htm.
These ports are pretty straightforward (not to say dumb) and most probably can be optimized. But they have been extensively tested in our Rubik's cube solving machine, so be confident the algorithm is working.
C sources reside in the ckociemba
folder. Running make
in a root folder will compile a binary called solve
. It accepts a cube representation as a commandline argument, and writes the solution to the standard output. You can, of course, use it as a library.
Python version is located in kociemba
directory. It is quite slow. It is probably better just to use Python's subprocess module and run a compiled C version. However, if you want pure Python, I would recommend running it with PyPy. On my Raspberry Pi version B it takes up to one minute to find a solution for a single cube.
In the root directory you can find a test script that contains some tests, generated by the original Java implementation. Run it like this:
$ python test.py
There is also a bigger test file called javares.txt. You can feed it to the test.py:
$ python test.py javares.txt