45
12. Rubik’s Magic Cube Robert Snapp [email protected] Department of Computer Science University of Vermont Robert R. Snapp © 2012 12. Rubik’s Magic Cube CS 32, Fall 2012 1 / 45

12. Rubik's Magic Cubersnapp/puzzles/lectures/rubik.pdfRubik’s Magic Cube Ernö Rubik invented this celebrated puzzle in 1974. When completed, each of the six faces displays a common

  • Upload
    others

  • View
    4

  • Download
    0

Embed Size (px)

Citation preview

Page 1: 12. Rubik's Magic Cubersnapp/puzzles/lectures/rubik.pdfRubik’s Magic Cube Ernö Rubik invented this celebrated puzzle in 1974. When completed, each of the six faces displays a common

12. Rubik’s Magic Cube

Robert [email protected]

Department of Computer ScienceUniversity of Vermont

Robert R. Snapp © 2012 12. Rubik’s Magic Cube CS 32, Fall 2012 1 / 45

Page 2: 12. Rubik's Magic Cubersnapp/puzzles/lectures/rubik.pdfRubik’s Magic Cube Ernö Rubik invented this celebrated puzzle in 1974. When completed, each of the six faces displays a common

Rubik’s Magic Cube

Ernö Rubik invented this celebrated puzzle in 1974.When completed, each of the six faces displays acommon color, usually white, yellow, red, orange, blueand 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 colorarrangement.

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.

Robert R. Snapp © 2012 12. Rubik’s Magic Cube CS 32, Fall 2012 2 / 45

Page 3: 12. Rubik's Magic Cubersnapp/puzzles/lectures/rubik.pdfRubik’s Magic Cube Ernö Rubik invented this celebrated puzzle in 1974. When completed, each of the six faces displays a common

David Singmaster’s Notation

David Singmaster1 published one of the first analyses of the Magic Cube. Heintroduced 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 D 24.

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

Robert R. Snapp © 2012 12. Rubik’s Magic Cube CS 32, Fall 2012 3 / 45

Page 4: 12. Rubik's Magic Cubersnapp/puzzles/lectures/rubik.pdfRubik’s Magic Cube Ernö Rubik invented this celebrated puzzle in 1974. When completed, each of the six faces displays a common

Singmaster’s Operations: U

Once the cube has been positioned, we define aset of rotation operations that maintain theorientation of the center cubies.

For example, U denotes a quarter turn of theUpper face in the clockwise direction.

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

U 0 denotes a quarter turn of the Upper face inthe counter-clockwise direction. (N.B.,U 0 D U 3.)

U

U 2

U 0

Robert R. Snapp © 2012 12. Rubik’s Magic Cube CS 32, Fall 2012 4 / 45

Page 5: 12. Rubik's Magic Cubersnapp/puzzles/lectures/rubik.pdfRubik’s Magic Cube Ernö Rubik invented this celebrated puzzle in 1974. When completed, each of the six faces displays a common

Singmaster’s Operations: F

F denotes a quarter turn of the Front face in theclockwise direction.

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

F 0 denotes a quarter turn of the Front face in thecounter-clockwise direction. (N.B., F 0 D F 3.)

F

F 2

F 0

Robert R. Snapp © 2012 12. Rubik’s Magic Cube CS 32, Fall 2012 5 / 45

Page 6: 12. Rubik's Magic Cubersnapp/puzzles/lectures/rubik.pdfRubik’s Magic Cube Ernö Rubik invented this celebrated puzzle in 1974. When completed, each of the six faces displays a common

Singmaster’s Operations: D

D denotes a quarter turn of the Down face in theclockwise direction.

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

D0 denotes a quarter turn of the Down face inthe counter-clockwise direction. (N.B.,D0 D D3.)

D

D2

D0

Robert R. Snapp © 2012 12. Rubik’s Magic Cube CS 32, Fall 2012 6 / 45

Page 7: 12. Rubik's Magic Cubersnapp/puzzles/lectures/rubik.pdfRubik’s Magic Cube Ernö Rubik invented this celebrated puzzle in 1974. When completed, each of the six faces displays a common

Singmaster’s Operations: B

B denotes a quarter turn of the Back face in theclockwise direction.

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

B 0 denotes a quarter turn of the Back face in thecounter-clockwise direction. (N.B., B 0 D B3.)

B

B2

B 0

Robert R. Snapp © 2012 12. Rubik’s Magic Cube CS 32, Fall 2012 7 / 45

Page 8: 12. Rubik's Magic Cubersnapp/puzzles/lectures/rubik.pdfRubik’s Magic Cube Ernö Rubik invented this celebrated puzzle in 1974. When completed, each of the six faces displays a common

Singmaster’s Operations: L

L denotes a quarter turn of the Left face in theclockwise direction.

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

L0 denotes a quarter turn of the Left face in thecounter-clockwise direction. (N.B., L0 D L3.)

L

L2

L0

Robert R. Snapp © 2012 12. Rubik’s Magic Cube CS 32, Fall 2012 8 / 45

Page 9: 12. Rubik's Magic Cubersnapp/puzzles/lectures/rubik.pdfRubik’s Magic Cube Ernö Rubik invented this celebrated puzzle in 1974. When completed, each of the six faces displays a common

Singmaster’s Operations: R

R denotes a quarter turn of the Right face in theclockwise direction.

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

R0 denotes a quarter turn of the Right face in thecounter-clockwise direction. (N.B., R0 D R3.)

R

R2

R0

Robert R. Snapp © 2012 12. Rubik’s Magic Cube CS 32, Fall 2012 9 / 45

Page 10: 12. Rubik's Magic Cubersnapp/puzzles/lectures/rubik.pdfRubik’s Magic Cube Ernö Rubik invented this celebrated puzzle in 1974. When completed, each of the six faces displays a common

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.

Robert R. Snapp © 2012 12. Rubik’s Magic Cube CS 32, Fall 2012 10 / 45

Page 11: 12. Rubik's Magic Cubersnapp/puzzles/lectures/rubik.pdfRubik’s Magic Cube Ernö Rubik invented this celebrated puzzle in 1974. When completed, each of the six faces displays a common

Part I: Step 1 — Restore the Upper Cross

1a Select a color for the upper face (e.g, green), andan 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 shouldbe easy to bring this cubie to the correctlocation.

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, andrepeat the above until all four upper edges are inplace. You should see a green cross.

Robert R. Snapp © 2012 12. Rubik’s Magic Cube CS 32, Fall 2012 11 / 45

Page 12: 12. Rubik's Magic Cubersnapp/puzzles/lectures/rubik.pdfRubik’s Magic Cube Ernö Rubik invented this celebrated puzzle in 1974. When completed, each of the six faces displays a common

Part I: Step 2 — Restore the Upper Corners

2a For each corner cubie in the Down layer thatbelongs in the Upper layer:

i Rotate the Down layer (using the D operation) untilthis cubie is directly below its desired postion.Rotate the entire cube so that the desired positionis under your right thumb (upper-right-frontposition).

ii Apply the operation R0D0RD one, three, or fivetimes, until this corner cubie is in the correctposition, with the correct orientation. (This will notdestroy the cross, obtained in Step 1.)

urf

drf

Robert R. Snapp © 2012 12. Rubik’s Magic Cube CS 32, Fall 2012 12 / 45

Page 13: 12. Rubik's Magic Cubersnapp/puzzles/lectures/rubik.pdfRubik’s Magic Cube Ernö Rubik invented this celebrated puzzle in 1974. When completed, each of the six faces displays a common

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

2b For each Upper layer corner cubie that isincorrectly placed, or incorrectly rotated,

i Rotate the entire cube until the misplaced cubie isunder your right thumb.

ii Place the cubie in the Down layer using R0D0RD:

iii Then apply step 2a (above) to move this cubie inthe correct position.

2c Apply the above steps until the entire upper layeris complete.

Robert R. Snapp © 2012 12. Rubik’s Magic Cube CS 32, Fall 2012 13 / 45

Page 14: 12. Rubik's Magic Cubersnapp/puzzles/lectures/rubik.pdfRubik’s Magic Cube Ernö Rubik invented this celebrated puzzle in 1974. When completed, each of the six faces displays a common

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

Robert R. Snapp © 2012 12. Rubik’s Magic Cube CS 32, Fall 2012 14 / 45

Page 15: 12. Rubik's Magic Cubersnapp/puzzles/lectures/rubik.pdfRubik’s Magic Cube Ernö Rubik invented this celebrated puzzle in 1974. When completed, each of the six faces displays a common

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. Thenew upper layer should have a blue center.

Robert R. Snapp © 2012 12. Rubik’s Magic Cube CS 32, Fall 2012 15 / 45

Page 16: 12. Rubik's Magic Cubersnapp/puzzles/lectures/rubik.pdfRubik’s Magic Cube Ernö Rubik invented this celebrated puzzle in 1974. When completed, each of the six faces displays a common

Part II: Step 4 — Restore the Middle LayerThe key operation is RU 0R0FR0F 0RU 0 which swaps and inverts ul and fr.

4a Rotate the entire cube until a front-right (fr) edgeis incorrect, or flipped. (Assume the right edge ofthe white face is incorrect.)

4b Locate the correct edge (e.g., the red-whiteedge).

Case A: If the correct edge is in the middlelayer:

i Rotate the entire cube so thatthe correct edge is a front-right(fr) edge. (Note, the red-whiteedge is in the middle layer.)

ii Perform the sequenceRU 0R0FR0F 0RU 0 which willplace the correct edge in theupper layer (at ul ).

iii Apply Case B.

fr

ul

Robert R. Snapp © 2012 12. Rubik’s Magic Cube CS 32, Fall 2012 16 / 45

Page 17: 12. Rubik's Magic Cubersnapp/puzzles/lectures/rubik.pdfRubik’s Magic Cube Ernö Rubik invented this celebrated puzzle in 1974. When completed, each of the six faces displays a common

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 edgeis still the front-right (fr ) edge.

ii Rotate the upper layer (using U

operations) so that the correctedge is an upper-left (ul ) edge.

iii Apply the operationRU 0R0FR0F 0RU 0.

iv If the correct edge needs to beflipped, apply Case C.

Case C: If a middle edge is flipped in thecorrect location:

i Apply the operationRU 0R0FR0F 0RU 0 twice.

Robert R. Snapp © 2012 12. Rubik’s Magic Cube CS 32, Fall 2012 17 / 45

Page 18: 12. Rubik's Magic Cubersnapp/puzzles/lectures/rubik.pdfRubik’s Magic Cube Ernö Rubik invented this celebrated puzzle in 1974. When completed, each of the six faces displays a common

Part II: Step 4 — Restore the Middle Layer (cont.)

The top row illustrates two successive occurrences of Case B. The left two diagrams show howthe red-yellow edge is moved into its correct position with RU 0R0FR0F 0RU 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 theorange-white edge is moved into its correct position, but with an incorrect orientation. ApplyingRU 0R0FR0F 0RU 0 moves it back into the top layer, but flipped. A third application, bringsthe orange-white edge into the correct position and orientation.

Robert R. Snapp © 2012 12. Rubik’s Magic Cube CS 32, Fall 2012 18 / 45

Page 19: 12. Rubik's Magic Cubersnapp/puzzles/lectures/rubik.pdfRubik’s Magic Cube Ernö Rubik invented this celebrated puzzle in 1974. When completed, each of the six faces displays a common

Part III: Restoring the Upper LayerNow that the bottom and middle layers are complete, every cubie in the upper layerhas 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 eachfaces 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 theblue face of each faces upwards.

Robert R. Snapp © 2012 12. Rubik’s Magic Cube CS 32, Fall 2012 19 / 45

Page 20: 12. Rubik's Magic Cubersnapp/puzzles/lectures/rubik.pdfRubik’s Magic Cube Ernö Rubik invented this celebrated puzzle in 1974. When completed, each of the six faces displays a common

Part III: Step 5 — Flip the New Upper Edges5. 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

FRUR0U 0F 0

and repeat Step 5 as many times as required.

Robert R. Snapp © 2012 12. Rubik’s Magic Cube CS 32, Fall 2012 20 / 45

Page 21: 12. Rubik's Magic Cubersnapp/puzzles/lectures/rubik.pdfRubik’s Magic Cube Ernö Rubik invented this celebrated puzzle in 1974. When completed, each of the six faces displays a common

Part III: Step 6 — Restore the New Upper EdgesAt 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 orangesides of the blue cross match all four of the corresponding center cubies. (Twist theupper layer using a succession of U operations, to see if this occurs. If so procede toStep 7.) If you are not so lucky, twist the upper layer until exactly one of the sides ofthe blue cross matches its center cubie. Rotate the cube so that the matching sidecubie is in the front face. In the figures below the matching cubie happens to be red.

RWYO ROWY RYOW

Apply the sequence RUR0URU 2R0 until the sides of the four top edge cubies match.

Robert R. Snapp © 2012 12. Rubik’s Magic Cube CS 32, Fall 2012 21 / 45

Page 22: 12. Rubik's Magic Cubersnapp/puzzles/lectures/rubik.pdfRubik’s Magic Cube Ernö Rubik invented this celebrated puzzle in 1974. When completed, each of the six faces displays a common

Part III: Step 7 — Place the Upper CornersWe shall now ensure that each upper corner is in thecorrect position. (Don’t worry now about their orienta-tions; those will be restored in Step 8.)

Compare the colors of each upper corner with those ofthe adjacent centers. If all three match, even if the ori-entation is wrong, then this piece is in the correct po-sition. In the diagram at right, the upper-left-front (ulf)corner (red-white-blue) is in the correct position. Theupper-right-front (urf ) corner (yellow-orange-blue) isnot.

ulfulb urb

The key sequence of Step 7 is L0URU 0LUR0U 0, which rotates (or cycles) the upperthree corners (ulf, ulb, urb ), in a clockwise direction, while maintaining the positionsand orientation of the remaining 23 cubies.

Robert R. Snapp © 2012 12. Rubik’s Magic Cube CS 32, Fall 2012 22 / 45

Page 23: 12. Rubik's Magic Cubersnapp/puzzles/lectures/rubik.pdfRubik’s Magic Cube Ernö Rubik invented this celebrated puzzle in 1974. When completed, each of the six faces displays a common

Step 7 — Place the Upper Corners (cont.)7a. If no upper corners are in their correct positions, apply L0URU 0LUR0U 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 thecorrectly placed corner is near your right thumb, in the upper-right-front (urf )position. Then apply L0URU 0LUR0U 0 (once or twice) until all four upper cornersare correctly placed.

Robert R. Snapp © 2012 12. Rubik’s Magic Cube CS 32, Fall 2012 23 / 45

Page 24: 12. Rubik's Magic Cubersnapp/puzzles/lectures/rubik.pdfRubik’s Magic Cube Ernö Rubik invented this celebrated puzzle in 1974. When completed, each of the six faces displays a common

Part III: Step 8 — Twist the Upper CornersAt this point every cube is in the correct position. However, two or more corners mayhave an incorrect orientation.

The key sequence of Step 8 is R0D0RD, which you already practiced in Step 2.

8a. Rotate the entire cube until an incorrectlyoriented (twisted) corner is located near yourright thumb. (It should be in the urf position.)

8b. Apply the sequence R0D0RD (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

Robert R. Snapp © 2012 12. Rubik’s Magic Cube CS 32, Fall 2012 24 / 45

Page 25: 12. Rubik's Magic Cubersnapp/puzzles/lectures/rubik.pdfRubik’s Magic Cube Ernö Rubik invented this celebrated puzzle in 1974. When completed, each of the six faces displays a common

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

8c. Now rotate only the upper layer, by applying oneor more U operations, until the next twisted cubeis near your right thumb in the urf position.

8d. Repeat steps 2 and 3 until every corner iscorrectly oriented.

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

operations.

8f. Fix yourself an ice-cream cone.

urf

urf

urf

urf

Robert R. Snapp © 2012 12. Rubik’s Magic Cube CS 32, Fall 2012 25 / 45

Page 26: 12. Rubik's Magic Cubersnapp/puzzles/lectures/rubik.pdfRubik’s Magic Cube Ernö Rubik invented this celebrated puzzle in 1974. When completed, each of the six faces displays a common

Summary

Step Operations Goal

upper(green)cross

Use the six basic operations to move the desired edge immediately be-low its home, without moving the other upper edges. Then rotate thatface one-half turn.

To flip an inverted edge, apply F 0UL0U 0.

upper(green)corners

Use R0D0RD to swap (and twist) the urf and drf corners. After eachmisplaced corner has been moved to the down (blue) layer, use the Doperator to move it immediately below its home. Then apply R0D0RDa sufficient number of times, so that it is correctly placed and correctlyoriented.

flipentirecube

Easy as pie! Turn the entire cube upside down so that the blue centeron top and the completed green face is the new down layer.

middleedges

Use RU 0R0FR0F 0RU 0 to swap and flip the ul and fr edges, withoutdisplacing the other cubies on the lower two layers.

Robert R. Snapp © 2012 12. Rubik’s Magic Cube CS 32, Fall 2012 26 / 45

Page 27: 12. Rubik's Magic Cubersnapp/puzzles/lectures/rubik.pdfRubik’s Magic Cube Ernö Rubik invented this celebrated puzzle in 1974. When completed, each of the six faces displays a common

Summary (cont.)

Step Operations Goal

orientupperedges

If the blue facets on the upper face form a corner, rotate the cube sothat the corner is at ul, u, and ub. If the upper facets of the upper edgesform a blue line, rotate the cube so that the blue line runs from left toright (ul, u, ur). Apply FRUR0U 0F 0 until a blue cross is displayed.

restoreupperedges

Apply U until the the uf edge matches the color of the front face. Thenapply RUR0URU 2R0 until every upper edge matches the side faces.

placeuppercorners

If an upper corner is correctly placed, rotate the entire cube so thatthis becomes the urf corner. Then apply L0URU 0LUR0U 0 until eachcorner is correctly placed. urf

twistuppercorners

Apply U until urf is twisted. Then apply R0D0RD until this urf is cor-rect. Repeat until every corner is untwisted. Apply U to restore thecube.

Robert R. Snapp © 2012 12. Rubik’s Magic Cube CS 32, Fall 2012 27 / 45

Page 28: 12. Rubik's Magic Cubersnapp/puzzles/lectures/rubik.pdfRubik’s Magic Cube Ernö Rubik invented this celebrated puzzle in 1974. When completed, each of the six faces displays a common

How Many States are in the Cube?Claim: A 3 � 3 � 3 Rubik’s cube can be placed in exactly

N D 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 beformed 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. Firstnote 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.

Robert R. Snapp © 2012 12. Rubik’s Magic Cube CS 32, Fall 2012 28 / 45

Page 29: 12. Rubik's Magic Cubersnapp/puzzles/lectures/rubik.pdfRubik’s Magic Cube Ernö Rubik invented this celebrated puzzle in 1974. When completed, each of the six faces displays a common

How Many States are in the Cube?We will use the multiplication principle to count the number N of configurations thatcan be obtained by a sequence of the operations, L, R, U , D, B and F .

Let,

N1 D number of configurations of the 6 centers

N2 D number of configurations of the 12 edges

N3 D number of configurations of the 8 corners

Then, our first estimate of N is

N D N1 �N2 �N3:

What is the value of N1?

Robert R. Snapp © 2012 12. Rubik’s Magic Cube CS 32, Fall 2012 29 / 45

Page 30: 12. Rubik's Magic Cubersnapp/puzzles/lectures/rubik.pdfRubik’s Magic Cube Ernö Rubik invented this celebrated puzzle in 1974. When completed, each of the six faces displays a common

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 D 1:

Thus,

N D 1 �N2 �N3:

What is the value of N2?

Robert R. Snapp © 2012 12. Rubik’s Magic Cube CS 32, Fall 2012 30 / 45

Page 31: 12. Rubik's Magic Cubersnapp/puzzles/lectures/rubik.pdfRubik’s Magic Cube Ernö Rubik invented this celebrated puzzle in 1974. When completed, each of the six faces displays a common

Estimating N2

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

N2 D 12Š � 212D 1; 961; 990; 553; 600

ways to arrange the 12 edges.

What can we say about N3?

Robert R. Snapp © 2012 12. Rubik’s Magic Cube CS 32, Fall 2012 31 / 45

Page 32: 12. Rubik's Magic Cubersnapp/puzzles/lectures/rubik.pdfRubik’s Magic Cube Ernö Rubik invented this celebrated puzzle in 1974. When completed, each of the six faces displays a common

Estimating N3

Since there are 8 corner cubicles (locations for the corners), there are 8Š ways toorder the corners. In addition each corner can be twisted three different ways. Thissuggests that, at most,

N3 D 8Š � 38D 264; 539; 520

ways to arrange the eight corners.Does

N D 1 � .12Š � 212/ � .8Š � 38/‹

Robert R. Snapp © 2012 12. Rubik’s Magic Cube CS 32, Fall 2012 32 / 45

Page 33: 12. Rubik's Magic Cubersnapp/puzzles/lectures/rubik.pdfRubik’s Magic Cube Ernö Rubik invented this celebrated puzzle in 1974. When completed, each of the six faces displays a common

Counting the Configurations of Rubik’s CubeThis number,

1 � .12Š � 212/ � .8Š � 38/ D 519; 024; 039; 293; 878; 272; 000

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

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

Robert R. Snapp © 2012 12. Rubik’s Magic Cube CS 32, Fall 2012 33 / 45

Page 34: 12. Rubik's Magic Cubersnapp/puzzles/lectures/rubik.pdfRubik’s Magic Cube Ernö Rubik invented this celebrated puzzle in 1974. When completed, each of the six faces displays a common

InvariantsConsider a “puzzle” that concerns the value of a variable x. Initially, x D 0. Everysecond a coin is tossed. If the coin lands heads then we add 4 to x. If the coin landstails, 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?

Robert R. Snapp © 2012 12. Rubik’s Magic Cube CS 32, Fall 2012 34 / 45

Page 35: 12. Rubik's Magic Cubersnapp/puzzles/lectures/rubik.pdfRubik’s Magic Cube Ernö Rubik invented this celebrated puzzle in 1974. When completed, each of the six faces displays a common

InvariantsCorrect! The answer is no. Since x begins as an even number, and every possibleoperation (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.

Robert R. Snapp © 2012 12. Rubik’s Magic Cube CS 32, Fall 2012 35 / 45

Page 36: 12. Rubik's Magic Cubersnapp/puzzles/lectures/rubik.pdfRubik’s Magic Cube Ernö Rubik invented this celebrated puzzle in 1974. When completed, each of the six faces displays a common

Invariants and Loyd’s 14-15 Puzzle

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

How many states are realizable?

Robert R. Snapp © 2012 12. Rubik’s Magic Cube CS 32, Fall 2012 36 / 45

Page 37: 12. Rubik's Magic Cubersnapp/puzzles/lectures/rubik.pdfRubik’s Magic Cube Ernö Rubik invented this celebrated puzzle in 1974. When completed, each of the six faces displays a common

Invariants (cont.)For the space to wind up in the lower-right corner, there must have been an evennumber of vertical moves, and an even number of horizontal moves. Consequently,only permutations that swap and even number of pieces are possible. For Loyd’spuzzle, only half of the 16Š states are realizable.

Anne Scott used invariants to exactly count the number of possible states for Rubik’scube.

Robert R. Snapp © 2012 12. Rubik’s Magic Cube CS 32, Fall 2012 37 / 45

Page 38: 12. Rubik's Magic Cubersnapp/puzzles/lectures/rubik.pdfRubik’s Magic Cube Ernö Rubik invented this celebrated puzzle in 1974. When completed, each of the six faces displays a common

Reexamining the allowed corner twists

Place a 0, 1, or a 2 on each corner face,as shown at right. The initial sums are thencomputed for each face, and recorded undercolumn I of the table. Sums are also com-puted following each legal quarter turn. Notethat ever entry is a multiple of 3. This latterproperty is preserved for every sequence oflegal operations.

However, if one were able to twist a singlecorner, one-third of a turn, in either direc-tion, the sums of the adjacent faces changeto numbers that are not multiples of 3.

Consequently, only one-third of the totalnumber of corner twists 38 can be realizedusing 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 Sums

Face 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

Robert R. Snapp © 2012 12. Rubik’s Magic Cube CS 32, Fall 2012 38 / 45

Page 39: 12. Rubik's Magic Cubersnapp/puzzles/lectures/rubik.pdfRubik’s Magic Cube Ernö Rubik invented this celebrated puzzle in 1974. When completed, each of the six faces displays a common

Reexamining the allowed edge flipsPlace a 0 or 1 on each edge, and constructa stationary blue window for each face, asshown. The initial sum of the values that ap-pear in the blue windows is computed undercolumn I in the table. It can be shown thatthe window sum will always be a multiple of2, and even number, after every sequence ofoperations. (After F U , for example, it equals6.)

However, flipping any single edge results inan odd window sum. Consequently, it is notpossible to invert a single edge using a se-quence or rotations.

Thus only one-half of the 212 edge states arerealizable.

1

1

1

00

1

00

1

0

0

11

0

0

10

1

10

001

1

Blue-Window Sums

I L R U D F B

sum 12 8 8 8 8 8 8

Robert R. Snapp © 2012 12. Rubik’s Magic Cube CS 32, Fall 2012 39 / 45

Page 40: 12. Rubik's Magic Cubersnapp/puzzles/lectures/rubik.pdfRubik’s Magic Cube Ernö Rubik invented this celebrated puzzle in 1974. When completed, each of the six faces displays a common

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. Eachsequence of operations always moves a multiple of 4 pieces. It is thus impossible tointerchange just two corners, or just two edges.

Thus,

ND1

2�

1

2�

1

3� 12Š � 212

� 8Š � 38

D 43; 252; 003; 274; 489; 856; 000:

Robert R. Snapp © 2012 12. Rubik’s Magic Cube CS 32, Fall 2012 40 / 45

Page 41: 12. Rubik's Magic Cubersnapp/puzzles/lectures/rubik.pdfRubik’s Magic Cube Ernö Rubik invented this celebrated puzzle in 1974. When completed, each of the six faces displays a common

Some Symmetrical StatesLet Fs D FB 0 denote a move called a front slice. Similarly,let Rs D RL0 denote the right slice, and Us D UD0 denote the upper slice.

“Dots” “Chessboard” “Cross”

RmF 0mR0

mFm F 2s R2

s U 2s R0L2F 2

s U 2R2s F 2

s D2R0

The definitions of Rm, R0m, Fm, and F 0

m appear below.

Robert R. Snapp © 2012 12. Rubik’s Magic Cube CS 32, Fall 2012 41 / 45

Page 42: 12. Rubik's Magic Cubersnapp/puzzles/lectures/rubik.pdfRubik’s Magic Cube Ernö Rubik invented this celebrated puzzle in 1974. When completed, each of the six faces displays a common

Singmaster’s Operations: Rm

Start with yellow on top, blue in front, and red atright. Rm denotes a quarter turn of the middlelayer (only) parallel to the direction of R. Theeasiest way to complete this is to rotate both theright face, and the middle layer behind the rightface, one quarter turn clockwise, followed by R0.

R2m denotes a half turn of the middle layer

behind the right face.

R0m denotes a quarter turn of the middle layer,

behind the right face, in the counter-clockwisedirection, i.e., parallel to R0. (N.B., R0

m D R3m.)

Rm

R2m

R0m

Robert R. Snapp © 2012 12. Rubik’s Magic Cube CS 32, Fall 2012 42 / 45

Page 43: 12. Rubik's Magic Cubersnapp/puzzles/lectures/rubik.pdfRubik’s Magic Cube Ernö Rubik invented this celebrated puzzle in 1974. When completed, each of the six faces displays a common

Singmaster’s Operations: Fm

Fm denotes a quarter turn of the middle layer(only) parallel to the direction of F . The easiestway to complete this is to rotate both the frontface, and the middle layer behind the front face,one quarter turn clockwise, followed by F 0.

F 2m denotes a half turn of the middle layer

behind the front face.

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

behind the front face, in the counter-clockwisedirection, i.e., parallel to F 0. (N.B., F 0

m D F 3m.)

Fm

F 2m

F 0m

Robert R. Snapp © 2012 12. Rubik’s Magic Cube CS 32, Fall 2012 43 / 45

Page 44: 12. Rubik's Magic Cubersnapp/puzzles/lectures/rubik.pdfRubik’s Magic Cube Ernö Rubik invented this celebrated puzzle in 1974. When completed, each of the six faces displays a common

Singmaster’s Operations: Um

Um denotes a quarter turn of the middle layer(only) parallel to the direction of U . The easiestway to complete this is to rotate both the upperface, and the middle layer behind the upper face,one quarter turn clockwise, followed by U 0.

U 2m denotes a half turn of the middle layer

behind the upper face.

U 0m denotes a quarter turn of the middle layer,

behind the upper face, in the counter-clockwisedirection, i.e., parallel to U 0. (N.B., U 0

m D U 3m.)

Um

U 2m

U 0m

Robert R. Snapp © 2012 12. Rubik’s Magic Cube CS 32, Fall 2012 44 / 45

Page 45: 12. Rubik's Magic Cubersnapp/puzzles/lectures/rubik.pdfRubik’s Magic Cube Ernö Rubik invented this celebrated puzzle in 1974. When completed, each of the six faces displays a common

References1 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

Mathematical Plays, Second Edition, Vol. 4, A. K. Peters, Natick, MA, 2004.3 John Ewing and Czes Kosniowski, 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

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

Robert R. Snapp © 2012 12. Rubik’s Magic Cube CS 32, Fall 2012 45 / 45