Generalised Rubik’s cube algorithm to go from any valid cube state A to any valid cube state B.

algorithmscombinatoricsrubiks-cube

For a $3 \times 3 \times 3$ cube, there are several known algorithms to go from any valid state of the cube to the solved state, $S$, of the cube (same color on each side).

How about a more general question: an algorithm to go from any valid starting state $A$ to any valid end state $B$

i.e. $B \in \{ $ Set of all valid $3 \times 3 \times 3$ rubiks cube configs $\} – \{A\}$.

A trivial algorithm would be: go from $A$ to $S$ and then reverse the steps required to go from $B$ to $S$

However this algorithm is stupid. Can we do better?

Best Answer

Imagine repainting the cube in state $B$ to make it look like $S$, and keep track of how you paint each piece. Now apply these repaintings of the individual pieces to the cube in state $A$. This gives you a new cube state $C$. Apply the cube-solving algorithm to $C$; the steps that turn $C$ into $S$ will also turn $A$ into $B$.