# Optimal solutions for Rubik's Cube

There are many algorithms to solve scrambled Rubik's Cubes. The maximum number of face turns needed to solve any instance of the Rubik's Cube is 20.^{[1]} This number is also known as the diameter of the Cayley graph of the Rubik's Cube group. An algorithm that solves a cube in the minimum number of moves is known as God's algorithm.

There are two common ways to measure the length of a solution. The first is to count the number of quarter turns. The second is to count the number of face turns. A move like F2 (a half turn of the front face) would be counted as 2 moves in the quarter turn metric and as only 1 turn in the face metric.

## Move notation

{{#invoke:main|main}}

To denote a sequence of moves on the 3×3×3 Rubik's Cube, this article uses "Singmaster notation",^{[2]} which was developed by David Singmaster.

The letters L,R,F,B,U,D indicate a quarter clock-wise turn of the left, right, front, back, up and down face respectively. Half turns are indicated by appending a 2. A quarter counter clock-wise turn is indicated by appending a prime symbol ( ′ ).

## Lower bounds

It can be proven by counting arguments that there exist positions needing at least 18 moves to solve. To show this, first count the number of cube positions that exist in total, then count the number of positions achievable using at most 17 moves. It turns out that the latter number is smaller.

This argument was not improved upon for many years. Also, it is not a constructive proof: it does not exhibit a concrete position that needs this many moves. It was conjectured that the so-called superflip would be a position that is very difficult. A Rubik's Cube is in the superflip pattern when each corner piece is in the correct position, but each edge piece is incorrectly oriented.^{[3]} In 1992, a solution for the superflip with 20 face turns was found by Dik T. Winter, of which the minimality was shown in 1995 by Michael Reid, providing a new lower bound for the diameter of the cube group. Also in 1995, a solution for superflip in 24 quarter turns was found by Michael Reid, with its minimality proven by Jerry Bryan.^{[3]} In 1998, a new position requiring more than 24 quarter turns to solve was found. The position, which was called a 'superflip composed with four spot' needs 26 quarter turns.^{[4]}

## Upper bounds

The first upper bounds were based on the 'human' algorithms. By combining the worst-case scenarios for each part of these algorithms, the typical upper bound was found to be around 100.

Perhaps the first concrete value for an upper bound was the 277 moves mentioned by David Singmaster in early 1979. He simply counted the maximum number of moves required by his cube-solving algorithm.^{[5]} Later, Singmaster reported that Elwyn Berlekamp, John Conway, and Richard Guy had come up with a different algorithm that took at most 160 moves. Soon after, Conway’s Cambridge Cubists reported that the cube could be restored in at most 94 moves.^{[5]}^{[6]}

### Thistlethwaite's algorithm

The breakthrough was found by Morwen Thistlethwaite; details of Thistlethwaite's Algorithm were published in *Scientific American* in 1981 by Douglas Hofstadter. The approaches to the cube that lead to algorithms with very few moves are based on group theory and on extensive computer searches. Thistlethwaite's idea was to divide the problem into subproblems. Where algorithms up to that point divided the problem by looking at the parts of the cube that should remain fixed, he divided it by restricting the type of moves you could execute. In particular he divided the cube group into the following chain of subgroups:

Next he prepared tables for each of the right coset spaces . For each element he found a sequence of moves that took it to the next smaller group. After these preparations he worked as follows. A random cube is in the general cube group . Next he found this element in the right coset space . He applied the corresponding process to the cube. This took it to a cube in . Next he looked up a process that takes the cube to , next to and finally to .

Although the whole cube group is very large (~4.3×10^{19}), the right coset spaces and are much smaller.
The coset space is the largest and contains only 1082565 elements. The number of moves required by this algorithm is the sum of the largest process in each step.

Initially, Thistlethwaite showed that any configuration could be solved in at most 85 moves. In January 1980 he improved his strategy to yield a maximum of 80 moves. Later that same year, he reduced the number to 63, and then again to 52.^{[5]} By exhaustively searching the coset spaces it was later found that the best possible number of moves for each stage was 7, 10, 13, and 15 giving a total of 45 moves at most.^{[8]}

### Kociemba's Algorithm

Thistlethwaite's algorithm was improved by Herbert Kociemba in 1992. He reduced the number of intermediate groups to only two:

As with Thistlethwaite's Algorithm, he would search through the right coset space to take the cube to group . Next he searched the optimal solution for group . The searches in and were both done with a method equivalent to IDA*. The search in needs at most 12 moves and the search in at most 18 moves, as Michael Reid showed in 1995. By generating also suboptimal solutions that take the cube to group and looking for short solutions in , you usually get much shorter overall solutions. Using this algorithm solutions are typically found of fewer than 21 moves, though there is no proof that it will always do so.

In 1995 Michael Reid proved that using these two groups every position can be solved in at most 29 face turns, or in 42 quarter turns. This result was improved by Silviu Radu in 2005 to 40.

### Korf's Algorithm

Using these group solutions combined with computer searches will generally quickly give very short solutions. But these solutions do not always come with a guarantee of their minimality. To search specifically for minimal solutions a new approach was needed.

In 1997 Richard Korf^{[9]} announced an algorithm with which he had optimally solved random instances of the cube. Of the ten random cubes he did, none required more than 18 face turns. The method he used is called IDA* and is described in his paper "Finding Optimal Solutions to Rubik's Cube Using Pattern Databases". Korf describes this method as follows

- IDA* is a depth-first search that looks for increasingly longer solutions in a series of iterations, using a lower-bound heuristic to prune branches once a lower bound on their length exceeds the current iterations bound.

It works roughly as follows. First he identified a number of subproblems that are small enough to be solved optimally. He used:

- The cube restricted to only the corners, not looking at the edges
- The cube restricted to only 6 edges, not looking at the corners nor at the other edges.
- The cube restricted to the other 6 edges.

Clearly the number of moves required to solve any of these subproblems is a lower bound for the number of moves you will need to solve the entire cube.

Given a random cube C, it is solved as iterative deepening. First all cubes are generated that are the result of applying 1 move to them. That is C * F, C * U, … Next, from this list, all cubes are generated that are the result of applying two moves. Then three moves and so on. If at any point a cube is found that needs too many moves based on the upper bounds to still be optimal it can be eliminated from the list.

Although this algorithm will always find optimal solutions, there is no worst case analysis. It is not known how many moves this algorithm might need. An implementation of this algorithm can be found here.^{[10]}

### Further improvements

In 2006, Silviu Radu further improved his methods to prove that every position can be solved in at most 27 face turns or 35 quarter turns.^{[11]} Daniel Kunkle and Gene Cooperman in 2007 used a supercomputer to show that all unsolved cubes can be solved in no more than 26 moves (in face-turn metric). Instead of attempting to solve each of the billions of variations explicitly, the computer was programmed to bring the cube to one of 15,752 states, each of which could be solved within a few extra moves. All were proved solvable in 29 moves, with most solvable in 26. Those that could not initially be solved in 26 moves were then solved explicitly, and shown that they too could be solved in 26 moves.^{[12]}
^{[13]}

Tomas Rokicki reported in a 2008 computational proof that all unsolved cubes could be solved in 25 moves or fewer.^{[14]} This was later reduced to 23 moves.^{[15]} In August 2008 Rokicki announced that he had a proof for 22 moves.^{[16]} Finally, in 2010, Tomas Rokicki, Herbert Kociemba, Morley Davidson, and John Dethridge gave the final computer-assisted proof that all cube positions could be solved with a maximum of 20 face turns.^{[1]}^{[17]}

In 2009, Tomas Rokicki proved that 29 moves in the quarter-turn metric is enough to solve any scrambled cube.^{[18]} And in 2014, Tomas Rokicki and Morley Davidson proved that the maximum number of quarter-turns needed to solve the cube is 26.
^{[19]}

The face-turn and quarter-turn metrics differ in the nature of their antipodes.^{[19]}
An antipode is a scrambled cube that is maximally far from solved, one that requires the maximum number of moves to solve. In the half-turn metric with a maximum number of 20, there are hundreds of millions of such positions. In the quarter-turn metric, only a single position (and its two rotations) is known that requires the maximum of 26 moves. Despite significant effort, no additional quarter-turn distance-26 positions have been found. Even at distance 25, only two positions (and their rotations) are known to exist. At distance 24, perhaps 150,000 positions exist.

## References

- ↑
^{1.0}^{1.1}God's Number is 20 Cite error: Invalid`<ref>`

tag; name "20 moves" defined multiple times with different content - ↑ {{#invoke:citation/CS1|citation |CitationClass=book }}
- ↑
^{3.0}^{3.1}Michael Reid's Rubik's Cube page M-symmetric positions - ↑ Posted to Cube lovers on 2 Aug 1998
- ↑
^{5.0}^{5.1}^{5.2}Template:Cite web - ↑ {{#invoke:citation/CS1|citation |CitationClass=book }}
- ↑ Template:Cite web
- ↑ Progressive Improvements in Solving Algorithms
- ↑ Template:Cite article
- ↑ Michael Reid's Optimal Solver for Rubik's Cube (requires a compiler such as gcc)
- ↑ Rubik can be solved in 27f
- ↑ Press Release on Proof that 26 Face Turns Suffice
- ↑ {{#invoke:citation/CS1|citation |CitationClass=conference }}
- ↑ Template:Cite arxiv
- ↑ Twenty-Three Moves Suffice — Domain of the Cube Forum
- ↑ twenty-two moves suffice
- ↑ SIAM J. Discrete Math., 27(2), 1082–1105
- ↑ Template:Cite web
- ↑
^{19.0}^{19.1}God's Number is 26 in the Quarter-Turn Metric

## External links

- How to solve the Rubik's Cube, a Wikibooks article that gives an overview over several algorithms that are simple enough to be memorizable by humans. However, such algorithms will usually not give an
*optimal*solution which only uses the minimum possible number of moves. - Herbert Kociemba's Two-Phase-Solver and Optimal Solver for Rubik's Cube
- Ryan Heise's Human version of the Thistlethwaite algorithm
- A New Upper Bound on Rubik's Cube Group, Silviu Radu
- Online Solver using modified Kociemba's Algorithm to balance optimization vs. compute cycles