You are on page 1of 45

Rubik’s Magic Cube

Lecture Notes for CS 32


Delivered Nov. 28 – Dec. 2, 2005

© Robert R. Snapp 2005


Rubik’s Magic Cube

Ernö Rubik invented this celebrated puz-


zle in 1974. When completed, each of the
six faces displays a common color, usually
white, yellow, red, orange, blue and green.

Questions:
1. How many different ways can six
colors be assigned to the six faces?
2. How are the colors of each pair of Rubik’s standard color arrangement.
opposite faces related at right?
The cube actually consists of 26 visible cubies, consisting of
• 6 single faced, centers, which are stationary.
• 12 double faced, edges.
• 8 triple faced, corners.
David Singmaster’s Notation

David Singmaster1 published one of the first analyses of the Magic Cube. He
introduced the following notation:

U
• U, for the Upper face,
• F , for the Front face, B

• D, for the Down face,


L
• B, for the Back face,
R
• L, for the Left face, and
F
• R, for the Right face.
D

Note that the Magic Cube can be oriented 24 ways within this coordinate system:
• the upper face can be chosen 6 different ways.
• for each upper face, the front face can be chosen 4 different ways.
• 6 × 4 = 24.

1. David Singmaster, Notes on Rubik’s Magic Cube, Enslow, Hillside, NJ, 1981.
Singmaster’s Operations: U

Once the cube has been positioned, we define a


set of rotation operations that maintain the
U
orientation of the center cubies.

For example, U denotes a quarter turn of the


Upper face in the clockwise direction.

U 2 denotes a half turn of the Upper face. (N.B., U2


U 2 = U U.)

U 0 denotes a quarter turn of the Upper face in


the counter-clockwise direction. (N.B., U 0 = U 3.)
U0
Singmaster’s Operations: F

F denotes a quarter turn of the Front face in the


clockwise direction. F

F 2 denotes a half turn of the Front face. (N.B.,


F 2 = F F .)

F 0 denotes a quarter turn of the Front face in F2


the counter-clockwise direction. (N.B., F 0 = F 3.)

F0
Singmaster’s Operations: D

D denotes a quarter turn of the Down face in D


the clockwise direction.

D 2 denotes a half turn of the Down face. (N.B.,


D 2 = DD.)

D 0 denotes a quarter turn of the Down face in D2


the counter-clockwise direction. (N.B., D 0 = D 3.)

D0
Singmaster’s Operations: B

B denotes a quarter turn of the Back face in the B


clockwise direction.

B 2 denotes a half turn of the Back face. (N.B.,


B 2 = BB.)

B 0 denotes a quarter turn of the Back face in the B2


counter-clockwise direction. (N.B., B 0 = B 3.)

B0
Singmaster’s Operations: L

L denotes a quarter turn of the Left face in the L


clockwise direction.

L2 denotes a half turn of the Left face. (N.B.,


L2 = LL.)

L0 denotes a quarter turn of the Left face in the L2


counter-clockwise direction. (N.B., L0 = L3.)

L0
Singmaster’s Operations: R

R denotes a quarter turn of the Right face in the R


clockwise direction.

R 2 denotes a half turn of the Right face. (N.B.,


R 2 = RR.)

R 0 denotes a quarter turn of the Right face in R2


the counter-clockwise direction. (N.B., R 0 = R 3.)

R0
Restore the Cube: Outline

Part I: Restore the upper face.


1. Restore the upper edges.
2. Restore the upper corners.

Part II: Restore the middle layer.


3. Turn the entire cube upside down.
4. Restore the middle edges.

Part III: Restore the final face.


5. Invert the upper edges.
6. Reposition the upper edges.
7. Reposition the upper corners.
8. Twist the upper corners.
Part I: Step 1 — Restore the Upper Cross

1a Select a color for the upper face (e.g, green), and


an adjacent color for the front face (e.g., white).

1b Identify the cubie that belongs in the upper-front


(uf ) edge, e.g., the green-white edge. It should
be easy to bring this cubie to the correct location.

1c If this colors of the uf edge need to be flipped,


then apply the sequence

F 0UL0U 0.

1d Rotate the entire cube one-quarter turn, and re-


peat the above until all four upper edges are in
place. You should see a green cross.
Part I: Step 2 — Restore the Upper Corners

2a For each corner cubie in the Down layer that be-


longs in the Upper layer:
i Rotate the Down layer (using the D opera-
tion) until this cubie is directly below its de-
sired postion. Rotate the entire cube so that urf
the desired position is under your right thumb
(upper-right-front position). drf
ii Apply the operation R 0D 0RD one, three, or
five times, until this corner cubie is in the
correct position, with the correct orientation.
(This will not destroy the cross, obtained in
Step 1.)
Part I: Step 2 — Restore the Upper Corners (cont.)

2b For each Upper layer corner cubie that is incor-


rectly placed, or incorrectly rotated,
i Rotate the entire cube until the misplaced cu-
bie is under your right thumb.
ii Place the cubie in the Down layer using
R 0D 0RD.
iii Then apply step 2a (above) to move this cubie
in the correct position.
2c Apply the above steps until the entire upper layer
is complete.
Part I: Step 2 — Restore the Upper Corners (cont.)
Part II: Step 3 — Turn the Cube Upside Down

Turn the entire cube upside down, so that the com-


pleted green layer is the bottom (or down) layer. The
new upper layer should have a blue center.
Part II: Step 4 — Restore the Middle Layer

The key operation is RU 0R 0F R 0F 0RU 0 which swaps and inverts ul and fr .

4a Rotate the entire cube until a front-right (fr ) edge


is incorrect, or flipped. (Assume the right edge of
the white face is incorrect.)
4b Locate the correct edge (e.g., the red-white edge).
Case A: If the correct edge is in the middle layer: ul
i Rotate the entire cube so that the correct
edge is a front-right (fr ) edge. (Note, the fr

red-white edge is in the middle layer.)


ii Perform the sequence RU 0R 0F R 0F 0RU 0
which will place the correct edge in the up-
per layer (at ul).
iii Apply Case B.
Part II: Step 4 — Restore the Middle Layer (cont.)

Case B: If the correct edge is on the top layer:


i Ensure that the misplaced edge is still the
front-right (fr ) edge.
ii Rotate the upper layer (using U operations)
so that the correct edge is an upper-left (ul)
edge.
iii Apply the operation RU 0R 0F R 0F 0RU 0.
iv If the correct edge needs to be flipped, apply
Case C.
Case C: If a middle edge is flipped in the correct lo-
cation:
i Apply the operation RU 0R 0F R 0F 0RU 0 twice.
Part II: Step 4 — Restore the Middle Layer (cont.)

The top row illustrates two successive occurrences of Case B. The left two di-
agrams show how the red-yellow edge is moved into its correct position with
RU 0 R 0 F R 0 F 0 RU 0 . The right two, show how the orange-yellow edge is moved into
its correct position by the same operation.

The bottom row illustrates an occurrence of Case B, that leads to a Case C. First the
orange-white edge is moved into its correct position, but with an incorrect orienta-
tion. Applying RU 0 R 0 F R 0 F 0 RU 0 moves it back into the top layer, but flipped. A third
application, brings the orange-white edge into the correct position and orientation.
Part III: Restoring the Upper Layer

Now that the bottom and middle layers are complete, every cubie in the upper
layer has a single blue face. In order to restore the upper face, one needs to
5. Flip the edge cubies so that the blue face of each
faces upwards.
6. Move the edge cubies to their final locations,
without destroying their orientation.
7. Move the corner cubies to their final locations.
8. Rotate the corner cubies (in place) so that the
blue face of each faces upwards.
Part III: Step 5 — Flip the New Upper Edges

5. Orient the cube so that it matches one of the four orientations:

“Blue Dot” “Blue Corner” “Blue Line” “Blue Cross”

a. If the ”Blue Cross” is displayed, move on to Step 6.


b. If the ”Blue Cross” is not displayed, apply the maneuver

F RUR 0U 0F 0

and repeat Step 5.


Part III: Step 6 — Restore the New Upper Edges

At this point of the solution, the bottom two layers should be solved, and a blue
cross, should appear on the top face. If you are very lucky, the red, white, yellow
and orange sides of the blue cross match all four of the corresponding center
cubies. (Twist the upper layer using a succession of U operations, to see if this
occurs. If so procede to Step 7.) If you are not so lucky, twist the upper layer
until exactly one of the sides of the blue cross matches its center cubie. Rotate
the cube so that the matching side cubie is in the front face. In the figures below
the matching cubie happens to be red.

RWYO ROWY RYOW


Apply the sequence RUR 0URU 2R 0 until the sides of the four top edge cubies
match.
Part III: Step 7 — Place the Upper Corners

We shall now ensure that each upper corner is in the


correct position. (Don’t worry now about their orien-
tations; those will be restored in Step 8.)
Compare the colors of each upper corner with those ulb urb
ulf
of the adjacent centers. If all three match, even if
the orientation is wrong, then this piece is in the
correct position. In the diagram at right, the upper-
left-front (ulf ) corner (red-white-blue) is in the correct
position. The upper-right-front (urf ) corner (yellow-
orange-blue) is not.

The key sequence of Step 7 is L0URU 0LUR 0U 0, which rotates (or cycles) the
upper three corners (ulf , ulb, urb), in a clockwise direction, while maintaining
the positions and orientation of the remaining 23 cubies.
Step 7 — Place the Upper Corners (cont.)

7a. If no upper corners are in their correct positions, apply L0URU 0LUR 0U 0
(once or twice) until one is. Then continue.
7b. If one corner is in its correct position, then rotate the entire cube so that
the correctly placed corner is near your right thumb, in the upper-right-
front (urf ) position. Then apply L0URU 0LUR 0U 0 (once or twice) until all
four upper corners are correctly placed.
Part III: Step 8 — Twist the Upper Corners

At this point every cube is in the correct position. However, two or more corners
may have an incorrect orientation.
The key sequence of Step 8 is R 0D 0RD, which you already practiced in Step 2.
8a. Rotate the entire cube until an incorrectly ori-
ented (twisted) corner is located near your right
thumb. (It should be in the urf position.) urf

8b. Apply the sequence R 0D 0RD (two or four times)


until this corner cube has the correct orientation.
Don’t worry about the middle and bottom layers: urf

they are temporarily messed up.


Part III: Step 8 — Twist the Upper Corners (cont.)

8c. Now rotate only the upper layer, by applying one


or more U operations, until the next twisted cube
urf
is near your right thumb in the urf position.

8d. Repeat steps 2 and 3 until every corner is cor-


rectly oriented.
urf

8e. Finally, restore the cube using one or more U op-


erations.

8f. Fix yourself an ice-cream cone. urf

urf
Summary

Step Operations Goal


Use the six basic operations to move the desired edge imme-
upper
diately below its home, without moving the other upper edges.
(green)
Then rotate that face one-half turn.
cross
To flip an inverted edge, apply F 0 U L0 U 0 .

Use R 0 D 0 RD to swap (and twist) the urf and drf corners. After
upper
each misplaced corner has been moved to the down (blue) layer,
(green)
use the D operator to move it immediately below its home.
corners
Then apply R 0 D 0 RD a sufficient number of times, so that it is
correctly placed and correctly oriented.
Easy as pie! Turn the entire cube upside down so that the blue
flip
center on top and the completed green face is the new down
entire
layer.
cube

Use RU 0 R 0 F R 0 F 0 RU 0 to swap and flip the ul and fr edges, with-


middle
out displacing the other cubies on the lower two layers.
edges
Summary (cont.)

Step Operations Goal


If the blue facets on the upper face form a corner, rotate the
orient
cube so that the corner is at ul, u, and ub. If the upper facets
upper
of the upper edges form a blue line, rotate the cube so that the
edges
blue line runs from left to right (ul, u, ur ). Apply F RUR 0 U 0 F 0
until a blue cross is displayed.
Apply U until the the uf edge matches the color of the front
restore
face. Then apply RU R 0 U RU 2 R 0 until every upper edge matches
upper
the side faces.
edges

If an upper corner is correctly placed, rotate the entire cube so


place
that this becomes the urf corner. Then apply L0 URU 0 LUR 0 U 0
upper
until each corner is correctly placed. urf
corners

Apply U until urf is twisted. Then apply R 0 D 0 RD until this urf


twist
is correct. Repeat until every corner is untwisted. Apply U to
upper
restore the cube.
corners
How Many States are in the Cube?

Claim: A 3 × 3 × 3 Rubik’s cube can be placed in exactly

N = 43, 252, 003, 274, 489, 856, 000

different configurations, using a sequence of legal moves based on L, R, U, D,


B and F , more than the number of seconds in 10 billion centuries.

Counting this number is sort of like counting the number of anagrams that can
be formed from a given set of letters. We thus count permutations.

Recall that there are three kinds of cubies: 8 corners, 12 edges, and 6 centers.
First note that it is impossible to exchange a three-sided corner with a two-sided
edge, and likewise we can’t exchange a center with either a corner or edge.
How Many States are in the Cube?

We will use the multiplication principle to count the number N of configurations


that can be obtained by a sequence of the operations, L, R, U, D, B and F .

Let,

N1 = number of configurations of the 6 centers


N2 = number of configurations of the 12 edges
N3 = number of configurations of the 8 corners

Then, our first estimate of N is

N = N1 × N2 × N3.

What is the value of N1?


Estimating N1

Since the locations of the centers are unchanged by each of the six basic
operations, they are also unchanged by any sequence of these operations.
Thus,

N1 = 1.

Thus,

N = 1 × N2 × N3.

What is the value of N2?


Estimating N2

Since there are 12 locations (cubicles) for each edge, there are 12! ways to order
the edges. In addition, each edge can be flipped in two different ways: e.g., the
red-blue edge can be red-side up, or blue-side up. This suggests that there are
at most

N2 = 12! × 212 = 1, 961, 990, 553, 600

ways to arrange the 12 edges.

What can we say about N3?


Estimating N3

Since there are 8 corner cubicles (locations for the corners), there are 8! ways to
order the corners. In addition each corner can be twisted three different ways.
This suggests that, at most,

N3 = 8! × 38 = 264, 539, 520

ways to arrange the eight corners.


Does

N = 1 × (12! × 212) × (8! × 38)?


Counting the Configurations of Rubik’s Cube

This number,

1 × (12! × 212) × (8! × 38) = 519, 024, 039, 293, 878, 272, 000

actually represents (exactly) the number of different ways that Rubik’s cube can
be reassembled, assuming that the centers are not rearranged.

Anne Scott (cf., Berlekamp, Conway, Guy, 2004), showed that this value overes-
timates the correct value of N by a factor of 12.
Invariants

Consider a “puzzle” that concerns the value of a variable x. Initially, x = 0.


Every second a coin is tossed. If the coin lands heads then we add 4 to x. If the
coin lands tails, we subract 2. Here is a sample sequence.

time (s.) 0 1 2 3 4 5 6 7 8 9 10
coin toss H T H H T T T T T H
x 0 4 2 6 10 8 6 4 2 0 4

Question: Can x ever equal 1?


Invariants

Correct! The answer is no. Since x begins as an even number, and every possible
operation (adding 4 or subtracting 2) preserves evenness, x will always be even.

In this context, evenness is said to be an invariant property , or an invariant (for


short), of x.
Invariants and Loyd’s 14-15 Puzzle

Sam Loyd (1841–1911) created many popular puzzles, including the celebrated
14–15 puzzle, shown above. Can you interchange just tiles labeled 14 and 15,
by sliding tiles horizontally or vertically into the space? (Loyd offered a $1000
prize to anyone who could.)

How many states are realizable?


Invariants (cont.)

For the space to wind up in the lower-right corner, there must have been an
even number of vertical moves, and an even number of horizontal moves. Con-
sequently, only permutations that swap and even number of pieces are possible.
For Loyd’s puzzle, only half of the 16! states are realizable.

Anne Scott used invariants to exactly count the number of possible states for
Rubik’s cube.
Reexamining the allowed corner twists

Place a 0, 1, or a 2 on each corner face, as


2 1
shown at right. The initial sums are then
0 0
computed for each face, and recorded un- 1 0 0 21 2
der column I of the table. Sums are also 2 1 2 1
computed following each legal quarter turn. 2 1
Note that ever entry is a multiple of 3. This
1 2 1 2
0 0
latter property is preserved for every se-
0 0
quence of legal operations.
Face Sums
However, if one were able to twist a single Face I L R U D F B
corner, one-third of a turn, in either direc- left 6 6 6 6 6 3 3
right 6 6 6 6 6 3 3
tion, the sums of the adjacent faces change
upper 0 3 3 0 0 3 3
to numbers that are not multiples of 3. down 0 3 3 0 0 3 3
front 6 3 3 6 6 6 6
Consequently, only one-third of the total back 6 3 3 6 6 6 6

number of corner twists 38 can be realized


using a sequence of legal operations.
Reexamining the allowed edge flips

Place a 0 or 1 on each edge, and construct


a stationary blue window for each face, as
shown. The initial sum of the values that ap- 0
1 1 1
pear in the blue windows is computed under 0 0
1
1
1 0
column I in the table. It can be shown that 0 0 0
the window sum will always be a multiple of 0 1 1 0
1 1
2, and even number, after every sequence of 0
operations. (After F U, for example, it equals 0
1
0
1
6.)

However, flipping any single edge results in Blue-Window Sums


an odd window sum. Consequently, it is not I L R U D F B
sum 12 8 8 8 8 8 8
possible to invert a single edge using a se-
quence or rotations.

Thus only one-half of the 212 edge states are


realizable.
How many states are expressible by the cube?

The final reduction factor is obtained by observing that only one-half of the 12!×
8! permutations of the locations of the 12 edges and 8 corners are realizable.
Each sequence of operations always moves a multiple of 4 pieces. It is thus
impossible to interchange just two corners, or just two edges.

Thus,

1 1 1
N= × × × 12! × 212 × 8! × 38
2 2 3

= 43, 252, 003, 274, 489, 856, 000


Some Symmetrical States

Let Fs = F B 0 denote a move called a front slice. Similarly,


let Rs = RL0 denote the right slice, and Us = UD 0 denote the upper slice.

“Dots” “Chessboard” “Cross”

0 R0 F
Rm Fm Fs2Rs2Us2 R 0L2Fs2U 2Rs2Fs2D 2R 0
m m

0 , F , and F 0 appear below.


The definitions of Rm , Rm m m
Singmaster’s Operations: Rm

Start with yellow on top, blue in front, and red at


right. Rm denotes a quarter turn of the middle
Rm
layer (only) parallel to the direction of R. The
easiest way to complete this is to rotate both the
right face, and the middle layer behind the right
face, one quarter turn clockwise, followed by R 0.
2 denotes a half turn of the middle layer
Rm 2
Rm
behind the right face.
0 denotes a quarter turn of the middle layer,
Rm
behind the right face, in the counter-clockwise
direction, i.e., parallel to R 0. (N.B., Rm
0 = R 3 .)
m 0
Rm
Singmaster’s Operations: Fm

Fm denotes a quarter turn of the middle layer


(only) parallel to the direction of F . The easiest
Fm
way to complete this is to rotate both the front
face, and the middle layer behind the front face,
one quarter turn clockwise, followed by F 0.
2 denotes a half turn of the middle layer
Fm
2
Fm
behind the front face.
0 denotes a quarter turn of the middle layer,
Fm
behind the front face, in the counter-clockwise
direction, i.e., parallel to F 0. (N.B., Fm
0 = F 3 .)
m
0
Fm
Singmaster’s Operations: Um

Um denotes a quarter turn of the middle layer


(only) parallel to the direction of U . The easiest
Um
way to complete this is to rotate both the upper
face, and the middle layer behind the upper
face, one quarter turn clockwise, followed by U 0.
2 denotes a half turn of the middle layer
Rm
2
Um
behind the upper face.
0 denotes a quarter turn of the middle layer,
Rm
behind the upper face, in the counter-clockwise
direction, i.e., parallel to U 0. (N.B., Um
0 = U 3 .)
m
0
Um
References

1. Christoph Bandelow, Inside Rubik’s Cube and Beyond, Birkhäuser, Boston, 1982.
2. Elwyn R. Berlekamp, John H. Conway, and Richard K. Guy, Winning Ways For Your Mathe-
matical Plays, Second Edition, Vol. 4, A. K. Peters, Natick, MA, 2004.
3. John Ewing and Czes Kośniowski, Puzzle It Out: Cube Groups and Puzzles, Cambridge
University Press, Cambridge 1982.
4. Alexander H. Frey, Jr. and David Singmaster, Handbook of Cubik Math, Enslow, Hillside,
NJ, 1982.
5. Martin Gardner, ed., The Mathematical Puzzles of Sam Loyd, Dover, NY, 1959.
6. David Joyner, Adventures in Group Theory: Rubik’s Cube, Merlin’s Magic & Other Mathe-
matical Toys, Johns Hopkins University Press, Baltimore, 2002.
7. Ernö Rubik, Tamás Varga, Gerzson Kéri, Györgi Marx, and Tamás Vkerdy, Rubik’s Cubic
Compendium, Oxford University Press, Oxford, 1987.
8. David Singmaster, Notes on Rubik’s Magic Cube, Enslow, Hillside, NJ, 1981.

You might also like