45
Rubik’s Magic Cube Lecture Notes for CS 32 Delivered Nov. 28 – Dec. 2, 2005 © Robert R. Snapp 2005

rubik

Embed Size (px)

Citation preview

Page 1: rubik

Rubik’s Magic Cube

Lecture Notes for CS 32

Delivered Nov. 28 – Dec. 2, 2005

© Robert R. Snapp 2005

Page 2: rubik

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

opposite faces related at right?Rubik’s standard color arrangement.

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.

Page 3: rubik

David Singmaster’s Notation

David Singmaster1 published one of the first analyses of the Magic Cube. He

introduced the following notation:

• U , for the Upper face,

• F , for the Front face,

• D, for the Down face,

• B, for the Back face,

• L, for the Left face, and

• R, for the Right face.

U

B

R

D

F

L

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.

Page 4: rubik

Singmaster’s Operations: U

Once the cube has been positioned, we define a

set of rotation operations that maintain the

orientation of the center cubies.

For example, U denotes a quarter turn of the

Upper face in the clockwise direction.

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

U2 = UU .)

U′ denotes a quarter turn of the Upper face in

the counter-clockwise direction. (N.B., U′ = U3.)

U

U2

U′

Page 5: rubik

Singmaster’s Operations: F

F denotes a quarter turn of the Front face in the

clockwise direction.

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

F2 = FF .)

F ′ denotes a quarter turn of the Front face in

the counter-clockwise direction. (N.B., F ′ = F3.)

F

F2

F ′

Page 6: rubik

Singmaster’s Operations: D

D denotes a quarter turn of the Down face in

the clockwise direction.

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

D2 = DD.)

D′ denotes a quarter turn of the Down face in

the counter-clockwise direction. (N.B., D′ = D3.)

D

D2

D′

Page 7: rubik

Singmaster’s Operations: B

B denotes a quarter turn of the Back face in the

clockwise direction.

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

B2 = BB.)

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

counter-clockwise direction. (N.B., B′ = B3.)

B

B2

B′

Page 8: rubik

Singmaster’s Operations: L

L denotes a quarter turn of the Left face in the

clockwise direction.

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

L2 = LL.)

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

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

L

L2

L′

Page 9: rubik

Singmaster’s Operations: R

R denotes a quarter turn of the Right face in the

clockwise direction.

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

R2 = RR.)

R′ denotes a quarter turn of the Right face in

the counter-clockwise direction. (N.B., R′ = R3.)

R

R2

R′

Page 10: rubik

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.

Page 11: rubik

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 ′UL′U′.

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.

Page 12: rubik

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

the desired position is under your right thumb

(upper-right-front position).

ii Apply the operation R′D′RD 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.)

urf

drf

Page 13: rubik

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′D′RD.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.

Page 14: rubik

Part I: Step 2 — Restore the Upper Corners (cont.)

Page 15: rubik

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.

Page 16: rubik

Part II: Step 4 — Restore the Middle Layer

The key operation is RU′R′FR′F ′RU′ 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:

i Rotate the entire cube so that the correct

edge is a front-right (fr ) edge. (Note, the

red-white edge is in the middle layer.)

ii Perform the sequence RU′R′FR′F ′RU′

which will place the correct edge in the up-

per layer (at ul).

iii Apply Case B.

fr

ul

Page 17: rubik

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′R′FR′F ′RU′.

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′R′FR′F ′RU′ twice.

Page 18: rubik

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 withRU ′R′FR′F ′RU ′. The right two, show how the orange-yellow edge is moved intoits correct position by the same operation.

The bottom row illustrates an occurrence of Case B, that leads to a Case C. First theorange-white edge is moved into its correct position, but with an incorrect orienta-tion. Applying RU ′R′FR′F ′RU ′ moves it back into the top layer, but flipped. A thirdapplication, brings the orange-white edge into the correct position and orientation.

Page 19: rubik

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.

Page 20: rubik

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

FRUR′U′F ′

and repeat Step 5.

Page 21: rubik

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′URU2R′ until the sides of the four top edge cubies

match.

Page 22: rubik

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

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.

ulfulb urb

The key sequence of Step 7 is L′URU′LUR′U′, 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.

Page 23: rubik

Step 7 — Place the Upper Corners (cont.)

7a. If no upper corners are in their correct positions, apply L′URU′LUR′U′

(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 L′URU′LUR′U′ (once or twice) until all

four upper corners are correctly placed.

Page 24: rubik

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′D′RD, 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.)

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

until this corner cube has the correct orientation.

Don’t worry about the middle and bottom layers:

they are temporarily messed up.

urf

urf

Page 25: rubik

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

is near your right thumb in the urf position.

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

rectly oriented.

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

erations.

8f. Fix yourself an ice-cream cone.

urf

urf

urf

urf

Page 26: rubik

Summary

Step Operations Goal

upper(green)cross

Use the six basic operations to move the desired edge imme-diately below its home, without moving the other upper edges.Then rotate that face one-half turn.

To flip an inverted edge, apply F ′UL′U ′.

upper(green)corners

Use R′D′RD to swap (and twist) the urf and drf corners. Aftereach misplaced corner has been moved to the down (blue) layer,use the D operator to move it immediately below its home.Then apply R′D′RD a sufficient number of times, so that it iscorrectly placed and correctly oriented.

flipentirecube

Easy as pie! Turn the entire cube upside down so that the bluecenter on top and the completed green face is the new downlayer.

middleedges

Use RU ′R′FR′F ′RU ′ to swap and flip the ul and fr edges, with-out displacing the other cubies on the lower two layers.

Page 27: rubik

Summary (cont.)

Step Operations Goal

orientupperedges

If the blue facets on the upper face form a corner, rotate thecube so that the corner is at ul, u, and ub. If the upper facetsof the upper edges form a blue line, rotate the cube so that theblue line runs from left to right (ul, u, ur ). Apply FRUR′U ′F ′

until a blue cross is displayed.

restoreupperedges

Apply U until the the uf edge matches the color of the frontface. Then apply RUR′URU2R′ until every upper edge matchesthe side faces.

placeupper

corners

If an upper corner is correctly placed, rotate the entire cube sothat this becomes the urf corner. Then apply L′URU ′LUR′U ′

until each corner is correctly placed. urf

twistupper

corners

Apply U until urf is twisted. Then apply R′D′RD until this urfis correct. Repeat until every corner is untwisted. Apply U torestore the cube.

Page 28: rubik

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.

Page 29: rubik

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?

Page 30: rubik

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?

Page 31: rubik

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?

Page 32: rubik

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)?

Page 33: rubik

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.

Page 34: rubik

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 10coin toss H T H H T T T T T Hx 0 4 2 6 10 8 6 4 2 0 4

Question: Can x ever equal 1?

Page 35: rubik

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.

Page 36: rubik

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?

Page 37: rubik

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.

Page 38: rubik

Reexamining the allowed corner twists

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

shown at right. The initial sums are then

computed for each face, and recorded un-

der column I of the table. Sums are also

computed following each legal quarter turn.

Note that ever entry is a multiple of 3. This

latter property is preserved for every se-

quence of legal operations.

However, if one were able to twist a single

corner, one-third of a turn, in either direc-

tion, the sums of the adjacent faces change

to numbers that are not multiples of 3.

Consequently, only one-third of the total

number of corner twists 38 can be realized

using a sequence of legal operations.

11

1

1 22

2 12

2

2

2

2 1

1

1

00

0 0

00

0 0

Face SumsFace I L R U D F B

left 6 6 6 6 6 3 3

right 6 6 6 6 6 3 3

upper 0 3 3 0 0 3 3

down 0 3 3 0 0 3 3

front 6 3 3 6 6 6 6

back 6 3 3 6 6 6 6

Page 39: rubik

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-

pear in the blue windows is computed under

column I in the table. It can be shown that

the window sum will always be a multiple of

2, and even number, after every sequence of

operations. (After FU , for example, it equals

6.)

However, flipping any single edge results in

an odd window sum. Consequently, it is not

possible to invert a single edge using a se-

quence or rotations.

Thus only one-half of the 212 edge states are

realizable.

1

1

1

00

1

00

1

0

0

11

0

0

10

1

10

001

1

Blue-Window SumsI L R U D F B

sum 12 8 8 8 8 8 8

Page 40: rubik

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,

N = 12

× 12

× 13

× 12! × 212 × 8! × 38

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

Page 41: rubik

Some Symmetrical States

Let Fs = FB′ denote a move called a front slice. Similarly,

let Rs = RL′ denote the right slice, and Us = UD′ denote the upper slice.

“Dots” “Chessboard” “Cross”

RmF ′mR′

mFm F2s R2

s U2s R′L2F2

s U2R2s F2

s D2R′

The definitions of Rm, R′m, Fm, and F ′

m appear below.

Page 42: rubik

Singmaster’s Operations: Rm

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

right. Rm denotes a quarter turn of the middle

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′.

R2m denotes a half turn of the middle layer

behind the right face.

R′m denotes a quarter turn of the middle layer,

behind the right face, in the counter-clockwise

direction, i.e., parallel to R′. (N.B., R′m = R3

m.)

Rm

R2m

R′m

Page 43: rubik

Singmaster’s Operations: Fm

Fm denotes a quarter turn of the middle layer

(only) parallel to the direction of F . The easiest

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 ′.

F2m denotes a half turn of the middle layer

behind the front face.

F ′m denotes a quarter turn of the middle layer,

behind the front face, in the counter-clockwise

direction, i.e., parallel to F ′. (N.B., F ′m = F3

m.)

Fm

F2m

F ′m

Page 44: rubik

Singmaster’s Operations: Um

Um denotes a quarter turn of the middle layer

(only) parallel to the direction of U . The easiest

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′.

R2m denotes a half turn of the middle layer

behind the upper face.

R′m denotes a quarter turn of the middle layer,

behind the upper face, in the counter-clockwise

direction, i.e., parallel to U′. (N.B., U′m = U3

m.)

Um

U2m

U′m

Page 45: rubik

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 Kosniowski, Puzzle It Out: Cube Groups and Puzzles, CambridgeUniversity 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 CubicCompendium, Oxford University Press, Oxford, 1987.

8. David Singmaster, Notes on Rubik’s Magic Cube, Enslow, Hillside, NJ, 1981.