Group theory, counting and parity
The maths of the Rubik's Cube: why it works.
You do not need maths to solve the cube, but the cube is full of it. Here are the ideas that mathematicians use, with a calculator you can try.
How many positions are there?
The cube has 8 corners and 12 edges. The corners can be arranged in 8! ways and each can be twisted three ways, but the last twist is decided by the others, so there are 8! × 3⁷ corner states. The edges can be arranged in 12! ways and flipped two ways, again with the last flip decided, so 12! × 2¹¹ edge states. A parity rule says half of those combinations are impossible, so divide by 2.
43,252,003,274,489,856,000positions: about 43 quintillion
If you could try one position every second, it would take about 1.4 trillion years to see them all, which is far longer than the universe has existed.
God's number is 20
Out of all those positions, how many moves do you need in the worst case? In 2010 a team led by Tomas Rokicki, with Herbert Kociemba, Morley Davidson and John Dethridge, used a lot of computer time to show that the answer is 20, when a half turn counts as one move. No cube ever needs more than 20 moves, and some positions need all 20. Human solves use many more, because we trade moves for steps we can remember.
How many times until it repeats?
Every algorithm, repeated enough times, brings the cube back to solved. The number of repeats is called the order. Try an algorithm below.
Some orders to try: R U R' U' has order 6, R U has order 105 (surprisingly large for two moves), and R2 U2 has order 6. The order is the least common multiple of the cycle lengths of all the pieces it moves.
Inverses and commutators
Every sequence has an inverse that undoes it: the same moves in reverse order, each turned the other way. A commutator is a sequence of the form A B A' B'. When A and B touch only a few pieces in common, the commutator moves only those, which is how many algorithms are designed. The sexy move R U R' U' is a commutator of R and U, and it is the building block of the beginner method.
Parity
Parity is the idea that a permutation is either even or odd, depending on how many swaps it takes. A quarter turn of a face is a 4-cycle of corners and a 4-cycle of edges, so it is odd for both. Every move changes both parities together, which is why the cube can never be in a state with just two edges swapped. On bigger cubes the same idea produces parity cases that need special algorithms.
Maths for learners
Keep exploring
FAQ
Cube maths questions
How many positions does a Rubik's Cube have?
43,252,003,274,489,856,000, about 43 quintillion. It comes from 8! × 3⁷ for the corners and 12! × 2¹¹ for the edges, divided by 2 because of a parity rule.
What is God's number?
20. In 2010 a team of researchers showed by computer that every position of the 3×3 can be solved in 20 moves or fewer, counting a half turn as one move. Some positions really do need 20.
Why does an algorithm repeat after a fixed number of times?
Because the moves permute and twist a finite number of pieces. Repeating the same permutation eventually brings every piece home, and the number of repeats is the order of the algorithm, for example 6 for R U R' U'.
Why can't I swap just two edges on a cube?
A parity rule links corners and edges: every quarter turn swaps pieces in both, so the permutation of the corners and of the edges always have the same parity. Swapping two edges alone would break the rule, so it can only be done together with a corner swap.
Start a conversation
Curious about the maths?
Our maths classes build on ideas like these. Tell us the learner's age and class and we will suggest a starting point.
- Tell us the learner’s age or grade and goals
- We’ll suggest a suitable class or learning path
- We’ll confirm format, timing and fees with a parent or guardian
Play it, don't just read it
Practise the cube in your browser
Free games that need no sign-up. Pick one and play for five minutes.
Pick a game
- Cube Move DetectiveTwo pictures of a Rubik's Cube, before and after. Find the turn, or the…Play
- Cube Notation QuizRead Rubik's Cube moves like a speedcuber: R, U', F2, Rw, M and x. Match…Play
- PLL Recognition TrainerSee the top of a Rubik's Cube from above and name the PLL case, from the…Play
- Balance ScalesEvery scale is balanced. Compare the shapes to find how many balance the…Play