Mathematics · Group Theory & Permutations
The Math of the Rubik's Cube
Invented by Hungarian architect Ernő Rubik in 1974, the Rubik's Cube is the world's best-selling puzzle toy — and one of the richest objects in all of mathematics. It connects abstract algebra, combinatorics, and computer science in a 3-inch plastic package with 43 quintillion possible positions. Only one of them is solved.
Got a cube in front of you? Type in the colours you can see and this page will work out every move you need — then walk you through them one turn at a time. Start with your cube ↓
Type in your cube. Get the moves.
Enter the colours you can actually see. The page checks that your cube is a real one, works out a complete solution, and then walks you through it a single turn at a time while a 3D copy makes the same move.
1 Hold your cube like this
White face on the bottom. Green face pointing at you. Keep it that way for the whole solve — never spin the whole cube around, only turn the faces the moves ask for.
- Top is yellow
- Bottom is white
- Front is green
- Back is blue
- Left is red
- Right is orange
Standard cubes always land this way round: put white down and green in front and red really will be on your left. Centres never move relative to each other, which is why they can be printed in for you below.
2 Fill in the 54 squares
Pick a colour and click squares — or click one square and just type w y g b o r, and the cursor walks along by itself. Arrow keys move it, backspace clears.
This is your cube unfolded flat, the way a cardboard box opens out. If you lose track of which square is which, check the 3D cube — it shows exactly what you have typed so far.
Drag to spin the view. This is your cube — it updates as you type.
Turn this cube by hand instead
3 Do these moves on your cube
Tip: use the ← and → arrow keys to step through without hunting for the buttons.
How This Page Knows Your Cube Is Impossible
Before it tries to solve anything, the page runs five checks on the colours you typed in. The first two are obvious. The last three are theorems.
- Nine of each colour. Six colours, fifty-four stickers.
- Every corner is a real corner, every edge a real edge. There is no white-yellow edge on a cube, because white and yellow are on opposite sides.
- Corner twists add up to a multiple of 3. You can never twist just one corner in place. Twist one, and another two must be twisted to compensate.
- Edge flips add up to an even number. Same idea: edges only ever flip in pairs.
- Corner swaps and edge swaps have matching parity. Swapping two corners forces two edges to swap as well.
The Seven Stages of the Solution
The solution above is the beginner's method — the route almost every cuber learns first. Instead of solving the cube all at once, it breaks an impossible problem into seven possible ones, and never undoes work it has already done.
Notice what stages 4 and 5 do: one fixes which way up pieces are, the other fixes where they are. Separating orientation from position is the single idea that makes the last layer solvable by a human. Every serious method — CFOP, Roux, ZZ — is a different way of splitting the same two questions.
Permutations & Combinations — 43 Quintillion Positions
The Rubik's Cube has exactly 43,252,003,274,489,856,000 possible configurations. That number — roughly 43 quintillion — comes directly from counting the ways the pieces can be arranged using combinatorics.
Where does that number come from?
The cube has 8 corner pieces, 12 edge pieces, and 6 center pieces (which never move relative to each other). Mathematicians calculate the arrangements like this:
Multiply the four numbers above together — the halved edge count already builds in the parity constraint (not every arrangement is physically reachable without taking the cube apart):
A Permutation Is an Arrangement
A permutation is any reordering of a set of objects. When you turn a face of the Rubik's Cube, you permute 8 pieces (4 corners and 4 edges around that face). A combination is a selection where order doesn't matter — but on the cube, order always matters (rotating U then R gives a different result than R then U). This is what makes the cube's math so rich.
Group Theory — The Algebra of the Cube
The set of all possible Rubik's Cube moves forms a mathematical structure called a group — specifically the Rubik's Cube Group, written as a subgroup of the symmetric group on 48 elements (the 48 visible stickers, excluding centers). This is a branch of abstract algebra that studies symmetry.
Any sequence of moves produces another valid cube state. You can never reach an "illegal" position by turning faces. The result of any two moves is also a move in the group.
The order of grouping doesn't change the result: (A·B)·C = A·(B·C). Applying three moves is the same regardless of which two you group together first.
There exists a "do nothing" move — the solved state. Applying it changes nothing. In math notation this is often written as e or I.
Every move has a reverse. U followed by U' returns to the original state. Every scramble can be exactly unscrambled.
The Order of a Move
In group theory, the order is how many times you must apply a move (or sequence of moves) to get back to the identity (the solved state).
A single face turn like U has order 4. But sequences can have surprisingly large orders. The common "Right-Hand Algorithm" (R U R' U') has order 6 — applying it 6 times returns the cube to its original state. Some complex combinations have orders in the thousands, meaning you'd have to repeat the exact same sequence thousands of times before the cube accidentally solved itself again!
Graph Theory — The Cube as a Map
Group theory says what the moves are. Graph theory lets us see them. Make every possible cube state a vertex, and draw an edge between two states whenever one quarter turn turns one into the other. This picture is called the Cayley graph of the cube group. It has 43 quintillion vertices, and every vertex has exactly 12 edges (U, U′, D, D′, R, R′, L, L′, F, F′, B, B′).
Green = solved. Colored edges match the face turned. Hover a vertex to see its shortest route home; click it to send the walker there. Or turn faces yourself:
| Distance | States | Growth |
|---|
What the graph shows
- Growth is exponential. Each ring holds roughly 9–10 times more states than the last (1, 12, 114, 1,068, …) until the graph starts to fold back on itself. That is why the ball must swallow all 43 quintillion states by radius 26.
- Squares mean commuting. U then D lands on the same vertex as D then U, so those two edges close a 4-cycle. Turns of opposite faces commute; turns of adjacent faces (like R and U) never do. Zoom to radius 2 and count the squares.
- Every cycle is a relation. Any closed loop is a move sequence that does nothing: U U U U, or (R U R′ U′) six times. The loop's length is the element's order.
- Solving is pathfinding. A scramble is a vertex; a solution is a path to green. God's number, 20 in the half-turn metric (26 in quarter turns), is the largest distance any vertex sits from solved: the diameter.
- Every vertex looks the same. Because a group acts the same from every state, the graph looks identical from every vertex. Graph theorists call this vertex-transitive.
Notation & Algorithms
Speedcubers around the world share solutions using Singmaster notation, invented by mathematician David Singmaster in 1979. Six letters, three modifiers, and infinite precision.
Famous Algorithms
How Speedcubers Use Algorithms
The CFOP method (Cross, F2L, OLL, PLL) breaks the solve into four stages, each handled by memorized algorithms. Top speedcubers know over 100 algorithms and execute them in under 5 seconds total — their fingers move faster than conscious thought, guided purely by pattern recognition trained into muscle memory.
3D Spatial Thinking
The Rubik's Cube is one of the most powerful tools ever invented for developing spatial reasoning — the ability to mentally rotate, reflect, and track objects in three dimensions. Brain imaging studies show that experienced cubers have measurably larger activation in the parietal lobe (the brain's spatial processing center) while solving.
When you solve a Rubik's Cube, you must simultaneously:
Architects, surgeons, pilots, engineers, and mathematicians all rely on strong spatial reasoning. Research from universities including Carnegie Mellon and MIT has found that Rubik's Cube practice measurably improves spatial IQ scores — making it one of the few toys with documented cognitive benefits.
The cube also introduces coordinate systems: every piece can be described by (x, y, z) coordinates, and every move is a rotation of a slice around one axis. This is the same mathematics used in 3D animation, robotics, flight simulation, and spacecraft attitude control.
Pattern Recognition & God's Number
A scrambled Rubik's Cube looks like chaos. A skilled cuber looks at the same cube and sees patterns — recognizable configurations with known solutions. This is a profound illustration of how mathematical expertise transforms perception: what looks random to a novice is structured information to an expert.
God's Number = 20
In 2010, mathematicians Tomas Rokicki, Herbert Kociemba, Morley Davidson, and John Dethridge proved the following: no matter how scrambled a Rubik's Cube is, it can always be solved in 20 or fewer moves. This maximum is called God's Number — the number of moves an omniscient being would need in the worst case.
The proof required checking all 43 quintillion positions. They used a symmetry reduction to collapse it to about 2.2 billion equivalence classes, then verified each using computers donated by Google. The total computation took 35 CPU-years, completed in weeks on modern hardware.
Pattern Databases in AI Solvers
The algorithm that enabled God's Number proof — Kociemba's two-phase algorithm — works by recognizing patterns. Phase 1 finds a short sequence that moves the cube into a special subgroup where only certain moves are needed. Phase 2 solves from there. This two-stage pattern recognition makes it fast enough to run on a phone.
Modern AI solvers (like DeepCubeA from USC, 2019) use deep reinforcement learning — the AI taught itself to solve the cube without human knowledge of algorithms, purely by exploring positions and learning which patterns lead toward solved. It solves in an average of 28 moves and finds solutions humans hadn't written algorithms for.