Rubik’s Cube Solver

Scramble it, then watch a two-phase solver take it apart move by move.

starting
drag to turn the view
solved
0 / 0

Solve a real cube, not just a simulated one

Hold your cube up to the camera, show it all six sides, and this works out the moves that solve it. Everything happens inside this page — reading the colours, searching for the solution, playing it back in 3D. Nothing is uploaded, nothing is installed.

How to use it

  1. Press “Scan a real cube with the camera” and allow the camera when the browser asks.
  2. Follow the six movements. You are never asked to name a face. Point any side at the camera to start, turn the cube a quarter to the left three times, then tip it twice. Each movement is drawn on screen.
  3. Check the colours. Anything the reader was unsure about is ringed; click a sticker to change it. The cube is checked for solvability before it is accepted.
  4. Watch it solve. Press play, or step through a move at a time with the arrow keys.
  5. Copy the moves onto your cube. Turn your cube so it matches the one on screen first — you chose the starting orientation when you scanned, so the moves are written for that way round.

No cube to hand? Press Scramble and watch it solve that instead, or type your own scramble in standard notation.

Move notation

Each letter is a quarter turn of one face, clockwise as you look at that face from outside the cube.

MoveMeans
UTurn the up face a quarter clockwise
DTurn the down face a quarter clockwise
RTurn the right face a quarter clockwise
LTurn the left face a quarter clockwise
FTurn the front face a quarter clockwise
BTurn the back face a quarter clockwise
R′The same turn anticlockwise; any letter takes a prime
R2A half turn, where direction does not matter

So R U R′ U′ is four quarter turns. Repeat it six times on a solved cube and the cube returns to solved — a quick way to check you are reading the notation the same way this page writes it.

How the solver works

A cube has about 43 quintillion positions, so searching them one at a time is hopeless. This uses Herbert Kociemba’s two-phase algorithm, which splits the problem in half.

Phase 1 drives the cube into the subgroup <U, D, R2, L2, F2, B2>: corners untwisted, edges unflipped, and the four middle-layer edges back in the middle layer. That never takes more than 12 moves. Phase 2 finishes the cube using only those restricted turns, in at most 18 more.

Both phases are IDA* searches, each guided by two pruning tables that give the minimum number of moves still needed, so hopeless branches are cut at once. The tables are built in your browser the first time the page loads, in roughly a third of a second.

The first answer found is not the end: a longer phase 1 often allows a much shorter phase 2, so the search keeps going and reports the best total it found. Every position can be solved in 20 moves or fewer — God’s number — and this usually lands on 20 or 21.

How the colours are read

Nothing is compared against a fixed table of colours, because a red sticker under a warm lamp reads much like an orange sticker under a cool one. Instead the six colours and the light each side was photographed under are worked out from the 54 samples themselves.

Two facts make that solvable: a cube has exactly nine stickers of each colour, and the centre sticker of a side is that side’s colour, which anchors every capture. In even room light this read all 54 stickers correctly in every test; in harsh, uneven light it is right about three times in four, and nearly every remaining case is caught because the result is not a solvable cube.

Questions

Does it work on a phone?

Yes. The rear camera is used where there is one, and the layout stacks on a narrow screen.

It says my cube cannot be solved. What went wrong?

Almost always a misread sticker. The message names the rule that was broken: a single flipped edge, a single twisted corner, or two pieces swapped. None of those can happen on a cube that was only ever turned, so correct the ringed stickers or scan again in flatter light. It can also mean the cube was taken apart and reassembled wrongly.

Is 20 moves guaranteed?

No. Every position can be solved in 20, but finding that shortest answer can take minutes. Two-phase gets within a move or two of it in well under a second, which is the better trade for a page you are waiting on.

Are my camera images sent anywhere?

No. The video never leaves the page. Only nine averaged colours per side are kept, and the solver runs in your browser — there is no server to send anything to.

Can I turn the cube myself?

Yes. Use the notation buttons, or the keys u r f d l b with shift for an anticlockwise turn. Drag the cube to look around it.