Laws of the Cube
Contents
- What are the Laws?
- Where do they come from?
- Cube Combinations
- God's Number — Solving a Cube Optimally
- Devil's Number — Solving all Cubes in One Algorithm
What are the Laws?
The cube makes perfect sense once you know how to think about it. But, probably that way you think about it the first time you pick it up isn't quite right. A lot of people look at a Rubik's cube and see a bunch of stickers (or colored pieces of plastic, because many modern cubes are stickerless; I will still call them stickers). But really you should see a bunch of pieces. If you take a cube apart (you can usually do this by turning one side 45 degrees and then gently twisting and pulling an edge piece out) you will find that the cube consists of 21 separate pieces: a 3-axis center system that has all 6 centers (each center has 1 color), 12 edge pieces (which each have 2 colors), and 8 corner pieces (which each have 3 colors).

Taking the cube apart teaches us a lot about it. First, you learn the simplest way to solve
it. Just take a scrambled cube apart and reassemble it as a solved cube! Second, because all 6 centers are physically attached to each other as one 3-axis system it is obvious that the centers never actually move relative to each other. The Green center is always opposite Blue. The White center is always opposite Yellow. The Red center is always opposite Orange. When Blue is on top and Red is in front, Yellow will always be on the right. So, you never really have to solve the centers. You can always just hold the cube so that the centers are wherever you want them to be and solve everything else relative to them. Third, edge pieces are physically distinct from corner pieces. Whenever you make any turn, an edge stays an edge and a corner stays a corner. Knowing all of this, you can actually see that my little website logo in the top left is an impossible cube state (I just put it that way to be my initials). It has a (reading clockwise) Green-White-Orange corner but also has the Green-White-Red centers going clockwise. On a real cube, the Green-White-Red centers are arranged in that clockwise order but the Green-White-Orange corner has those colors in that order only if reading counter clockwise.
Because the stickers on an edge or corner piece are physically all attached to each other, you can only really say to have solved a piece if it color matches its neighbors on all sides. Many people think they have solved one side of the cube when they make the example below on the left, but actually in that example basically nothing is solved! An actually solved side looks like the example below on the right.
The blue colors all match on the top face but the side colors of the pieces do not match, so they don't actually belong next to each other. | This is what a genuinely solved side of a cube looks like. |
It is very helpful to use the U, R, F, D, L, B names when referring to pieces. For example, you might say the U center (meaning the center piece on the U face), the FD edge (meaning the edge piece which has one sticker corresponding to the color of the F face and one to the color of the D face), or the URF corner (meaning the corner piece which has one sticker corresponding to the color of the U face, one to the color of the R face, and one to the color of the F face). Because a center always has one color, an edge always has two colors, and a corner always has three corners you can always tell what kind of piece is being referred to by how many letters it takes to name it.
Because there are 12 edge pieces, any given edge piece can always be found in 1 of 12 locations. The location of a piece is known as its permutation. The UF edge (meaning the has the UF colors on it) can be in the UF, UR, UB, UL, FL, FR, BR, BL, DF, DR, DB, or DL positions when the cube is scrambled. Because each edge piece has 2 colors, in any given location it can face 2 possible different directions. The direction a piece is facing is known as its orientation. The UF edge, even if it is in the UF spot, may have the U sticker on the U face (correctly oriented) or have the F sticker on the U face (incorrectly oriented). Because there are 8 corner pieces, any given corner piece has 1 of 8 possible permutations. Because a corner piece has 3 colors, in any given location it can face 3 possible different directions. A corner piece can be correctly oriented, twisted clockwise, or twisted counterclockwise.
The UR and UF edges here are flipped into the wrong orientation, but because they are in the spot they should be to be solved, they are still in the correct permutation. | The URF corner is twisted counterclockwise from the solved state and the ULF corner is twisted clockwise from the solved state. (You can tell which way it is twisted by the location of the U-face color, here blue, relative to where it should be to be solved.) |
Everything we have learned so far is called the Zeroth Law of the Cube. It is the Zeroth because it doesn't really tell you how the cube works, it only tells you what the cube is.
Shortcut:
If you are in a hurry, you can now move on to the first step of the Super Method.It turns out that the way the cube turns makes it so that some permutations and orientations of the pieces can never be reached, no matter how many moves you do. The rules on these are contained in the actual three laws of the cube.
To explain what that means, imagine you take apart a cube and lay out all the pieces close together the way a solved cube would be. You then take two pieces at a time and swap their places. After doing some amount of swaps you reassemble the cube with all those swaps performed. If you did an odd number of swaps, the cube cannot actually by solved by turning it! You have to disassemble it again. If you did an even number of swaps, then ordinary turns will be able to put all the pieces into the correct permutation.
If all the pieces you can't see are solved, then this cube is unsolvable because to solve it you would need to swap just 1 pair of pieces, the UR and UF edges. | If all the pieces you can't see are solved, then this cube is unsolvable because to sovle it you would need to swap just 1 pair of pieces, the URF and URB corners. |
If all the pieces you can't see are solved, then this cube is solvable because to solve it you need to swap 2 pairs of pieces, the UR and UF edges and the URF and URB corners. |
Again imagine you take a cube apart but this time instead of changing where any pieces are you decide to take edge pieces and put them in upside down. If you do an odd number of edge flips, the cube cannot be solved by turning it. If you did an even number of edge flips, then ordinary turns will be able to put all the edges back to correct orientation.
Only the UF edge is flipped and so if all the pieces you can't see are solved, then this cube is unsolvable. | Both the UF and UR edges are flipped and so if all the pieces you can't see are solved, then this cube is solvable. |
For one last time imagine you take a cube apart and now you start twisting corners. If a corner isn't twisted, you count that as a 0. If you twist a corner clockwise you count that as a 1. If you twist it counter clockwise you count that as a 2. If you add up the 8 numbers for corner orientation (either a 0, 1, or 2 for each of the 8 corners), you get the total corner orientation. If that number isn't a multiple of 3, the cube cannot be solved by turning it. If it is a multiple of 3, then ordinary turns will be able to put all the corners back to correct orientation.
Only the URF corner is twisted and so if all the pieces you can't see are solved, then this cube is unsolvable. | The URF corner is twisted counter clockwise (a 2) and the ULF corner is twisted clockwise (a 1) and so the total orientation is 3, making this cube solvable. | ||
The URF corner is twisted clockwise (a 1) and the ULF corner is twisted clockwise (a 1) and so the total orientation is 2, making this cube unsolvable. | The URF, ULF, and URB corners are each twisted clockwise and so the total orientation is 3, making this cube solvable. |
Where do they come from?
The Laws of the Cube come from just the basic facts of how a turn of a side works. Let's go through them one at a time, starting with the First Law. When you turn any side of the cube, for example the U-face, you cycle the locations (permutations) of the four edges of that side into each other and cycle the permutations of the four corners of that side into each other. To be concrete, if you start with a solved cube then a U turn moves the UF edge into the UL position, the UL edge into the UB position, the UB edge into the UR position, and the completes the cycle by moving the UR edge into the UF position. A similar cycle applies for the corners. So, in terms of permutations we can think of a U turn as this pair of cycles:
UF → UL → UB → UR → UF URF → ULF → ULB → URB → URF. |
Both of these cycles are 4-cycles
meaning they are of the form A → B → C → D → A, cycling between 4 distinct things. We can think about how to make a 4-cycle happen when we take the cube apart. We start with the pieces in the order ABCD and want to end with the order BCDA. To do this, we first swap the A and B pieces to get BACD. Then we swap the A and C pieces to get BCAD. Then we swap the A and D pieces to get BCDA as desired. So, it takes 3 swaps of pieces to make a 4-cycle. Therefore, a single turn of the cube does 3 edge swaps and 3 corner swaps, meaning it does an overall even number of total swaps. No matter what you do then, any legal cube will always have pieces permuted in such a way that it takes an even number of swaps to put them where they belong, giving us the First Law. We can actually learn even more here than what the first law tells us. A single turn of a side performs an odd number of edge swaps and an odd number of corner swaps, and so if you have a cube state in which the edges or corners (it will either be both or neither) are permuted in such a way that it takes an odd number of swaps to place them correctly, then you know that cube state will require an odd number of single turns to solve it.
To understand the second law, notice that if you have a correctly oriented U-face edge placed anywhere in the U layer, then doing U turns keeps the U sticker of that edge pointing up. Okay, so U turns don't change the orientation of edges in the U layer. Let's now add in R moves. All an R move can do in terms of the edge we are paying attention to is take that edge in or out of the U layer. If it is in the U layer, U moves don't change its orientation. If it isn't in the U layer, U moves don't move it at all. So, any combination of moves you do using only U and R moves that end with the U-face edge in the U layer will have that edge in the same orientation.
We start with a solved UF edge. | No matter what U face turns we do, it stays with the U sticker pointing Up. | R moves just take the edge in and out of the U layer without changing which way it faces. |
We need a third side to change edge orientation. Not even just a third side, but a third axis. If we allow turns of the L or D faces (L is on the same axis as R and D on the same axis as U) then we still can't change edge orientation (just move the edges around more, still facing the same way). But, suppose we can turn the F layer. If our U-face edge is in the UF position and we do an F turn followed by an R move, the the UF edge is now back in the U layer, but with the wrong orientation! In fact, by this same reasoning an F turn flips the orientation of all the edges on the F face (when comparing them to how they look when placed on the U face using U, R, L, and D moves). B moves similarly flip all the edges on the B face. This may make it sound like edge flips should have to come in multiples of 4, but actually it is possible to use an F move to flip 4 edges, then an R move to change out one of the edges on the F face for a new one and then do an F' move to flip the 4 edges on the F face again. 3 of those edges are now flipped back to how they were but the new one added and the one that was taken off with the R move are both flipped. So, in the end the combination F R F' flips only two edges. This gives us the Second Law.
Applying F R to our solved edge puts it in the U layer flipped! | Applying F R' F' R2 to a solved cube gives all edges oriented except the UF and UR edges, which are flipped! |
Now for the third and final law. Let's start with a solved URF corner and see what happens when we do different turns. When we do U turns, the U sticker stays pointing Up. So, again U turns don't change the orientation of a U corner. When we do a single R turn though, the U sticker no longer points toward U. Now the sticker the clockwise from where it should be. If we instead do an R2, the sticker now points down. All D moves keep it pointing down and so any combination of U, R2, and D that brings the corner back to the U layer will make it point up in the end. So, U, R2, and D don't change the orientation of the corner. The same story applies to adding in F2, L2, or B2.
We start with a solved UFF corner. | No matter what U face turns we do, it stays with the U sticker pointing Up. | R2 moves take the corner and point it Down, but any double moves that put it back in the top will have it pointing Up. |
Only single turns of R, F, L, B change the corner orientation with respect to the U and D faces. If we start with a solved cube and apply a single R turn and then use double turns of the side faces to bring any relevant corners to their respective U or D layers, we see that two of the four corners on the R face got twisted clockwise and two got twisted counter clockwise, which adds up to 6. This might make you think we need corner orientation to be a multiple of 6, but it is possible to do the same kind of thing we did for edge orientation. An R move twists 4 corners, a U' move takes one corner off of the R' face and puts a new one of, an R twists those new 4 corners. The result is 3 twisted corners all turned clockwise, which adds up to 3, giving the Third law.
Apply R U to our solved corner leaves it twisted clockwise! | Applying R U' R' to a solved cube leaves the corners in the ULb, URF, and DRF positions all twisted clockwise! |
How many ways are there to arrange a Rubik's cube?
Using the 3 Laws of the Cube we can calculate exactly how many cube states there are. Imagine you took the cube apart and are putting it back together. There are 12 places you can place the first edge you place, and you can place it in 2 different orientations at each of those 12 permutations. There are then 11 places you can place the next edge (because you can't put it where you put the first one) and can still pick from 2 orientations at each of those 11 places. You then have 10, 9, 8, 7, 6, 5, 4, 3, 2 places where you can put each of the subsequent edges except the last one and 2 choices for orientation each. For the last edge, it has to go in the only remaining open spot for an edge and its orientation has to be fixed so that the total number of edge flips is even. Therefore, for the edges there are (12 × 2) × (11 × 2) × (10 × 2) × (9 × 2) × (8 × 2) × (7 × 2) × (6 × 2) × (5 × 2) × (4 × 2) × (3 × 2) × (2 × 2) × (1 × 1) = 12! × 211 = 980,995,276,800 possible states for all the edges.
Similarly, there are 8 places you can place the first corner you place, and you can place it in 3 different orientations at each of those 8 permutations. There are then 7 places you can place the next corner, each with 3 orientations. You then have 6, 5, 4, 3 places where you can place each of the subsequence corners except the last two and 3 choices for orientation for each. For the last two corners, they have to be permuted so that the total number of swaps required to solve the corners and edges is even. One of them can be placed in any of 3 orientations but then the last corner must be oriented so that the total corner orientation adds up to a multiple of 3. So, once you have fixed the edges, the total number of possible corner states is (8 × 3) × (7 × 3) × (6 × 3) × (5 × 3) × (4 × 3) × (3 × 3) × (1 × 3) × (1 × 1) = 8! × 37/2 = 44,089,920.
We can take any one of those 44 millionish corner states for each of our 981 billionish edge states, so that overall the cube has a total of 980,995,276,800 × 44,089,920 = 12! × 8! × 210 × 37 = 43,252,003,274,489,856,000 ≈ 4.3 × 1019 = 43 Quintillion possible solvable states. To give you a sense for what that number is, 4.3 Quintillion dollars is 5 billion dollars for every person on Earth.That doesn't do the number justice, because it is impossible for you to understand how ridiculous having a billion dollars is. Imagine you could endure all possible weather and that somehow there was a bridge from the Earth to the Sun. No, that doesn't make sense but hear me out. Imagine you walk extremely fast. You walk so fast that you can walk all the way from the Earth to the Sun and back in just 1 day. That is about 300 million kilometers and will take you about 400 billion steps. Now imagine you live very long (I mean, you are in great shape from the walking) and that you have been doing that walk every single day for the last 300,000 years. Then, over that entire time you will have almost walked one step for each possible state of the cube. That means you need to have been walking to the Sun and back on the daily since the very first Homo Sapiens evolved in Africa to have taken a step for every state of the cube.
God's Number
If you were infinitely smart, you would be able to solve any cube in the fewest number of turns possible. The method that such an infinitely smart you would use to do so is called God's algorithm. What is the maximum number of turns that could take for any given solve? That is called God's number. The exact value of God's number depends on how you define a turn. There are three most common ways. There is Quarter-Turn-Metric (QTM), where turning any face of the cube by 90 degrees counts as a turn. This means that in QTM a U2 move counts as 2 moves. There is Half-Turn-Metric (HTM), where turning any face of the cube by any nonzero amount counts as a turn. This means that in HTM U, U2, and U' each count as 1 move. Lastly, there is Slice-Turn-Metric (STM), where turning any layer of the cube by any nonzero amount counts as a turn. This means that in STM an M' counts as 1 move. In both QTM and HTM an M' counts as 2 moves because when viewed as face turns it is really doing R' L and then rotating the cube.
HTM is the most common metric for most purposes. In 2010 it was proven that God's number in HTM is 20. Every cube state can be solved in 20 or fewer face turns. Doing this took a lot of extremely advanced math and a lot of computer time. The number of cube states is far too large (as we just saw) for human computers to every optimally solve all possible cube states, so it took a lot of mathematical sophistication about how to divide up the space of cube states in ways that could get such broad results. It has since been shown that God's number in QTM is 26. God's number in STM is still unknown. It is known that it must be 18, 19, or 20.
Devil's Number
If you were infinitely smart and infinitely lazy, you would be able to come up with a single move sequence so that if you applied that move sequence over and over to any cube then at some point in the sequence, the cube would be solved. Such an algorithm is called the Devil's algorithm. The number of moves in the Devil's algorithm is called the Devil's number. The Devil's algorithm has proven to be a much much more complicated math question than God's algorithm. The Devil's number is unknown. We know it must be between 34,326,986,725,785,600 and 43,251,683,287,486,463,996, meaning between 3.4 × 1016ish and 4.3 × 1019ish.