# How to solve a Rubik’s Cube using math

Although at first glance just a colorful and simple game, the Rubik’s Cube has been used in both competitions and mathematical research. The puzzle’s main objective is to recreate the original positioning (one color per side) by rotating the cube’s six faces. Originally called the ‘Magic Cube’ by its Hungarian inventor Erno Rubik, over 350 million have been sold since 1974.

According to the New York Post, Rubik himself originally could not solve his eponymous cube, although he was eventually able to complete it. Raymond Tran, a Computer Science graduate at UBC, explained the challenges of solving the puzzle in a mathematical essay paper.
“The cube is not easily solved because it does not hve a definite scrambled point,” Tran wrote. “This means that there is only one completed situation, where all the sides have one color each.”

In fact, there are 43,252,003,274,489,856,000 (43 quintillion) possible orientations, or permutations, for a 3x3x3 cube. This makes solving the cube solely by making random moves unreasonable.

It’s far from impossible to solve, however: It is currently estimated that the smallest number of moves needed to solve the cube from any starting position is as low as 20 moves. This number is commonly referred to as God’s Number.

Solving the 3x3x3 Rubik’s Cube mathematically primarily relies on a branch of algebra called group theory. When using group theory, mathematicians have shown that solving the Rubik’s Cube is almost trivial. In mathematics, a group consists of a set of objects and a binary operator which satisfy a certain mathematical conditions.

A permutation group is a finite group G whose elements are permutations of a given set and whose group operation is composition of permutations in G.

In other words, a permutation group is a set whose elements consist of different orderings of a finite list and whose group operation is the permutations which reorder the set in a different way. Therefore, the 3x3x3 Rubik’s Cube is a permutation group as it can be represented as an ordered list of 54 elements (six different colours, repeated nine times on individual cubes). In addition, since the cube’s six faces can rotate, these rotations can be considered operations or permutations.

Now, consider the Rubik’s Cube in this analogy: The cube permutations are group elements and the sequence of rotations of a face of the cube are binary operators. Move sequences can be viewed as permutations, or rearrangements of the cube where different move sequences that produce the same cube arrangement are considered the same permutation.

The hard part of solving the Rubik’s Cube is placing an individual piece in its correct location without affecting the rest of the cube. No move can exchange a single pair of individual cube pieces. In other words, moving a side of the cube will affect the position of other pieces as well. However, by using 3-cycles, or cycles of three individual cube pieces, one can effectively swap two cube pieces per cycle. Therefore, by using a series of moves which cycle between elements, one can achieve the same result as swapping two individual pieces directly.

To solve a Rubik’s Cube mathematically, the properties of cube group elements are needed to develop ‘macros,’ or special combinations of cube moves that will accomplish specific cube rearrangements. In The Mathematics of the Rubik’s Cube, it is noted that, by measuring the number of individual cubes changed by performing a sequence of moves, the required additional moves needed to reverse unwanted changes can be determined. It follows that useful pairs of moves typically only change a small number of individual pieces. These useful pairs of moves are called commutators. By applying a series of moves and their inverse operations, commutators ensure that only the desired piece is affected by a series of moves. Commutators are combined to build macros which ultimately describe an algorithm to solve the puzzle.

To actually complete a Rubik’s Cube, one straightforward approach is to solve it layer by layer. The difficult part is maintaining each layer’s structure as you further complete the cube. Suppose we want to flip two pieces but leave the other layers intact. We can ensure this by performing a rotation before applying our macro that will reverse the undesired change when the macro is applied.

Although the Rubik’s Cube was originally created as a puzzle, its intricacies have been marvelled over for many years by both hobbyists and mathematicians. By understanding the math behind how the Rubik’s Cube works, anyone can become an expert.