How our cube solver works, and how many moves it takes

Updated 2026-11-28 · by the Magic Cube: Solver and Guide team

The app solves every cube from 2x2 to 6x6 on the phone itself. The 2x2 is solved optimally (the fewest moves that exist), the 3x3 with Kociemba's two-phase algorithm, and the 4x4, 5x5 and 6x6 by reduction to a smaller cube. On 100 random cubes per size it averaged 8.5 moves on the 2x2, 19.4 moves on the 3x3, 68.6 moves on the 4x4, 101.7 moves on the 5x5 and 194.9 moves on the 6x6.

Benchmark: moves and time per size

Cube Average moves Median Shortest–longest Average time
2x2 8.5 9 5–10 under 0.01 s
3x3 19.4 20 16–21 0.3 s (search budget)
4x4 68.6 67 58–82 0.8 s
5x5 101.7 102 91–110 1.8 s
6x6 194.9 196 165–217 3.1 s

How we measured it.

You are welcome to cite these numbers; please link to this page.

2x2: optimal search

A 2x2 has 3,674,160 positions, few enough to search completely. The solver keeps one corner fixed and searches turns of the other three faces with iterative deepening (IDA*), guided by tables of how far each part of the cube is from solved. The first solution it finds is guaranteed to be the shortest. No 2x2 position needs more than 11 moves; our random cubes needed 8.5 on average.

3x3: Kociemba's two-phase algorithm

The 3x3 has about 43 quintillion positions, too many to search fully on a phone. Herbert Kociemba's two-phase algorithm splits the problem: phase one brings the cube into a subgroup that can be solved with only U, D and half turns of the other faces, and phase two solves it from there. The first solution appears almost at once; the solver then keeps searching for shorter ones.

Every 3x3 position can be solved in 20 moves or fewer (proven in 2010, the so-called God's number), and most positions need 18 at best. Our solver averaged 19.4 moves and never went over 21. For cubes mixed with up to about 12 moves it finds the shortest solution, so a cube that is two turns from solved is solved in two turns.

The solver is written in C for this app. It builds its tables in memory the first time it runs (about 0.2 seconds on a laptop) instead of downloading them, and it counts every position it visits against a hard limit, so a solve always ends.

4x4, 5x5 and 6x6: reduction

Big cubes are solved the way people solve them, by reduction: first group the center pieces of each face, then pair the edge pieces, and the cube now behaves like a 3x3, which the 3x3 solver finishes. The 4x4 adds the parity cases a 3x3 never has. The 6x6 is first reduced to a 5x5 (its inner centers and edges are grouped so it turns like a 5x5) and then solved as a 5x5.

Reduction does not give the shortest possible solution, which for big cubes is far beyond any computer, but it gives a reliable one in seconds without a server: 68.6 moves on average on the 4x4, 101.7 on the 5x5 and 194.9 on the 6x6. A big cube that is only a few turns from solved is a special case: the solver looks for the fewest moves first, so you are not handed 200 moves for a cube that needs three.

The Pro solver: offline and online together

For 4x4, 5x5 and 6x6, the app's Pro solver also sends the cube to our online solver and runs the offline solver at the same time, then keeps whichever solution is shorter. Our server runs a solver based on Daniel Walton's open-source rubiks-cube-NxNxN-solver, with more memory and larger tables than a phone can hold. On a 5x5 that typically brings the solution from about 100 moves down to about 80.

Without a connection the Pro solver simply uses the offline solution, so you always get one.

Why a solution is never wrong

Try it

Scan your cube and follow the solution in 3D, with or without internet.

Or learn to solve it yourself · FAQ