Scramble and solve
Scramble makes random turns, Solve runs the search on the current cube (any cube you built by hand), Play applies the solution one turn at a time.
Turn a face
U up, R right, F front, D down, L left, B back. A plain letter is a quarter turn clockwise looking at that face, 2 is a half turn, ' is counter-clockwise. Keyboard: U R F D L B, hold Shift for the counter-clockwise turn. You can also click a face of the net.
Scramble
Solution
Green turns are done. The gap marks the end of phase 1 and the start of phase 2.
Model checks
The science
The cube as a group
A Rubik's cube has 8 corner pieces and 12 edge pieces (the 6 centres only define the colours). A turn permutes corners among themselves and edges among themselves and twists corners (3 ways) and flips edges (2 ways). Turns can be undone and chained, so they form a group. Which cubes are reachable is fixed by three conservation laws: the corner twists add up to 0 mod 3, the edge flips add up to 0 mod 2, and the permutation parity of the corners equals that of the edges (a quarter turn is a 4-cycle of corners and a 4-cycle of edges, each an odd permutation, so both parities flip together). The count is 8! x 3^7 x 12! x 2^11 / 2 = 43,252,003,274,489,856,000 reachable cubes, about 4.3 x 10^19. The page tests this number against a second, independent split.
Facelets and cubies
The page keeps the cube as 54 coloured stickers (the "facelet model", Kociemba order U R F D L B). Each of the 18 moves is a permutation of these 54 places, and it is generated from the 3D geometry itself by rotating every sticker's position and normal by 90 degrees about the face axis, so the 3D twin and this page share one model. The solver converts the stickers into piece positions and orientations (a corner has orientation 0, 1 or 2 depending on where its white or yellow sticker points; an edge 0 or 1).
The two-phase search
Searching all 18 moves up to depth 20 is impossible (about 10^26 sequences). Kociemba's idea is to split the problem using the subgroup G1 = <U, D, R2, L2, F2, B2>. Phase 1 brings the cube into G1 using any moves: all corners untwisted, all edges unflipped and the four middle-layer edges back in the middle layer. That needs three small coordinates: twist (3^7 = 2187), flip (2^11 = 2048) and slice position (C(12,4) = 495). Phase 2 finishes inside G1 using only U, D and half turns of the other faces, with coordinates corner permutation (8! = 40320), edge permutation of the 8 outer edges (40320) and the order of the 4 middle edges (4! = 24). Both phases use iterative-deepening depth-first search with pruning tables: a breadth-first search from the goal over pairs of coordinates stores the true number of moves needed, and a branch is cut when that lower bound exceeds the depth left. On this page the tables hold about 1.08 M and 1.01 M entries for phase 1 and 0.97 M each for phase 2 and are built in your browser in a second or two.
What the numbers mean
The first solution found is returned, so lengths are typically 21 to 28 moves, not optimal. The true worst case over all 4.3 x 10^19 cubes is 20 moves ("God's number", proved by Rokicki, Kociemba, Davidson and Dethridge in 2010 with a large computer search). A human beginner method needs 100+ turns; this algorithm does not teach layer by layer, it shows how a computer searches the group. Scrambles from the Scramble button are random turn sequences, not uniformly random cubes (a 20-turn sequence is already very close to uniform, 30 is closer).
Independent checks
- Group order: the product of 8!, 3^7, 12!, 2^11 divided by 2 is compared with (3^7 x 2^11 x C(12,4)) x (8! x 8! x 4! / 2), the size of the quotient times the size of G1 that the solver relies on.
- Element orders: repeating R U must return to solved after exactly 105 repetitions, R U2 D' B D' after 1260 (the largest order any cube position has) and the commutator R U R' U' after 6. These are published values, obtained here by repeated application of the sticker permutations.
- Solver replay: random scrambles are solved and every solution is re-applied to the facelet model, which does not use the solver's piece tables. The 3D twin additionally checks its physical stickers against the same model after every turn.
Simplifications
The cube is a rigid ideal cube without friction, no moves are lost to mechanical limits, and the flat net is a diagram, not a rendering of a real toy. Mid-layer slice moves and whole-cube rotations are not offered because they are the same as combinations of face turns.
