Jump to main content

Devising an Algorithm for Solving Rubik's Cube

1
2
3
4
5
384 reviews

Abstract

If you're the kind of person who has taken apart your Rubik's cube in order to grease the inside parts so it will move more smoothly, this could be a great project for you. We'll show you three sets of move sequences that accomplish specific rearrangements of the cube. Can you devise a way to solve the cube using only these three move sequences?

Summary

Areas of Science
Difficulty
 
Time Required
Long (2-4 weeks)
Prerequisites
To do this project you should enjoy solving puzzles and thinking in three dimensions.
Material Availability
Readily available
Cost
Very Low (under $20)
Safety
No issues
Credits

Andrew Olson, Ph.D., Science Buddies

Sources

This project is based on:

Objective

The goal of this project is to devise an algorithm for solving Rubik's cube, using three sets of moves that each accomplish a specific function.

Introduction

Rubik's cube is an interesting 3-dimensional puzzle that challenges your spatial imagination and memory. The goal is to arrange the cube so that each side is a solid color, as shown in Figure 1.

Diagram of all sides of a rubiks cube
Figure 1. Diagram of a solved Rubik's cube. The six sides are named in pairs—up-down, front-back, and left-right. The up (U), front (F), and right (R) sides are visible. The remaining sides—left (L), back (B), and down (D)—are shown by the projected images.

Figure 1 also shows the labels we will be using when referring to sides of the cube. The six sides are named in pairs—up-down, front-back, and left-right. To refer to a specific side, we'll use the one-letter abbreviations shown in Figure 1 (U, D, F, B, L, R).

The cube is built in such a way that each side, row, and column can rotate (see Figure 2). With a few turns, the colors can be thoroughly mixed up. How can you get all of the squares back to their original positions? It's quite a puzzle to get the colors arranged properly again!

Diagram of the core of a Rubik's cube
Figure 2. Diagram of the core of a Rubik's cube. The core enables each side, row, and column of the cube to rotate.

In this project you'll learn three sequences of moves that accomplish specific rearrangements of the squares on the cube. Can you figure out how to use these three move sequences to solve the cube?

Before we present the moves, we need to introduce some more terminology, so that we can distinguish individual pieces on the cube. Rubik's cube is made of three different types of pieces. We will refer to them as center, corner, and edge pieces. The puzzle has six center pieces, one in the middle of each face. Each center piece has only one visible face. There are eight corner pieces on the puzzle. Each corner piece has three visible faces. The remaining twelve pieces are edge pieces, occupying the middle position along each edge of the cube. Each edge piece has two visible faces.

  Center Piece Corner Piece Edge Piece
Location
Center piece on a side of a Rubik's cube is highlighted in red
Four corner pieces on a side of a Rubik's cube are highlighted in red
Four edge pieces on a side of a Rubik's cube are highlighted in red
# in entire cube 6 8 12
Visible faces 1 3 2

Now we're almost ready to present the move sequences. Remember that each move sequence accomplishes a specific rearrangement of the pieces in the cube. For each move sequence, we'll describe that specific rearrangement both with a diagram and with words. Then we'll describe the move sequence in words and in a shorthand notation. You'll soon find that the shorthand makes it easier to execute the moves quickly and memorize them.

The shorthand notation is easy to learn. There are just five rules you need to know.

  1. When a side is rotated clockwise one quarter turn, the shorthand notation for the move is simply the letter of the side. For example, if you're supposed to rotate the right side one quarter turn clockwise, the shorthand would be R.
  2. When a side is rotated counterclockwise one quarter turn, the shorthand notation for the move is the letter + an apostrophe ('). For example, if you're supposed to rotate the right side counterclockwise one quarter turn, the shorthand would be R'.
  3. When a side is rotated twice (direction does not matter in this case), the shorthand notation for the move is the letter + 2. For example, if you're supposed to rotate the front side twice, the shorthand would be F2.
  4. For some of the moves, you will be moving only the center column of a side. For a clockwise rotation of one quarter turn, the shorthand is the letter of the side, followed by 'c' (for center column). For example, if you're supposed to rotate the center column of the front side one quarter turn clockwise, the shorthand would be Fc.
  5. Finally, if you're supposed to rotate the center column of a side counterclockwise one turn, just add an apostrophe ('). For example, if you're supposed to rotate the center column of the front side one quarter turn counterclockwise, the shorthand would be Fc'.

If you are unfamiliar with the Rubik's Cube moves, an online Rubik's Cube solver like the one listed in the Bibliography might help you gain familiarity with the moves.

Move Sequence #1

The first exchanges the positions of three edge pieces at once, altering nothing else. The three affected edge pieces are all on the center column: the bottom and top edge on the left side, and the opposite edge on the top side (see Figure 3). Repeating this sequence three times will restore the cube to its original configuration.

A six move sequence moves exactly three edge pieces in the center of a Rubik's cube
Figure 3. Move sequence #1: exchanging three consecutive edge pieces in the center 'slice' of the cube (yellow arrows at left). No other pieces are altered by this move sequence. Repeating this sequence three times restores the cube to its original configuration.

Detailed move explanation:

  1. Hold the cube so that the edge pieces are arranged in the center slice as shown in Figure 3. (The fourth edge is in the bottom plane, away from you on the cube, and will not be altered by this sequence.) Note the white side is the front face in Figure 3.
  2. Rotate the left side clockwise.
  3. Rotate the right side counterclockwise.
  4. Rotate the front side twice.
  5. Rotate the left side counterclockwise.
  6. Rotate the right side clockwise.
  7. Rotate the upper side twice.

Shorthand: L R' F2 L' R U2

Move Sequence #2

The second sequence 'cycles' five corner pieces: the four corners of the front face, plus the upper right corner. It also exchanges the positions of three the front side edge pieces, as shown in Figure 4.

An eight move sequence moves exactly three edge pieces and five corner pieces on a Rubik's cube
Figure 4. Move sequence #2: 'cycling' the four corner pieces of the front face. This sequence changes the positions of five corner pieces (yellow arrows) and three edge pieces (blue arrows). Compare the before and after pictures carefully. Repeating this sequence fifteen times restores the cube to it's original position.

Detailed move explanation:

  1. Hold the cube so that the corners you wish to rotate are on the front side (as shown above). Note the white side is the front face in Figure 4. The corner which you do not wish to rotate should be at the upper left of the front side.
  2. Rotate the upper side clockwise.
  3. Rotate the front side clockwise twice.
  4. Rotate the upper side counterclockwise.
  5. Rotate the front side clockwise.
  6. Rotate the upper side clockwise.
  7. Rotate the front side clockwise.
  8. Rotate the upper side counterclockwise.
  9. Rotate the front side clockwise twice.

Shorthand: U F2 U' F U F U' F2

Move Sequence #3

The third sequence 'flips' each of two opposite edge pieces in the upper layer without altering anything else on the cube, as shown in Figure 5. The two edge pieces wind up back in their original places, but with the original colors 'flipped.' Compare the before and after views to verify that this is true. Note that repeating this sequence twice restores the cube to the original position.

An eighteen move sequence flips the position of two center edge pieces on the top face of a Rubik's cube
Figure 5. Move sequence #3: 'flipping' two opposite edge pieces (marked by *'s in the 'before' view). The effect of this sequence is to 'flip' each of these two opposite edge pieces, without altering anything else. The two pieces will be in their original positions, but with colors reversed. Repeating this sequence restores the cube to the original position.

Detailed move explanation:

  1. Hold the cube as shown, so that the edge pieces you want to 'flip' are on the upper side, in the front and back positions. Note the white side is the front face in Figure 5.
  2. Rotate the center column of the front side clockwise (up).
  3. Rotate the upper side counterclockwise.
  4. Repeat steps 2 and 3 two more times.
  5. Rotate the upper side counterclockwise.
  6. Rotate the center column of the front side counterclockwise (down).
  7. Repeat steps 5 and 6 two more times.
  8. Rotate the upper side counterclockwise two times.

Shorthand: L R' F' L R' D' L R' B2 L' R D' L' R F' L' R U2

Note: Move sequence #3 is much easier to remember (and can be done more quickly) if you move the center column of the front side (a center 'slice' of the cube) rather than moving the left and right sides. Try this out with your own cube and verify that it does the same thing. (Unfortunately, the Java applet used for the animated diagrams does not provide for movements of center slices, so we can't show you this alternate sequence with an animated diagram.) Here is the move sequence in shorthand, using center slice moves (Fc means to rotate the center slice 'up' and Fc' means to rotate the center slice 'down'):
Alternate shorthand: [Fc U'] 3 times, then [U' Fc'] 3 times, then U2.

Can you figure out how to solve Rubik's cube using only these three sequences of moves?

Terms and Concepts

To do this project, you should do research that enables you to understand the following terms and concepts:

Questions

Bibliography

  • This project is based on the following article:
    Cao, C., 2002. A Simple Complexity, illumin 3(2), Fall, 2002. Retrieved December 19, 2006.
  • For information on algorithms, see:
    Wikipedia contributors, 2015. Algorithm, Wikipedia, The Free Encyclopedia. Retrieved April 2, 2014.

Potential spoiler alert! Here are some other ways to solve the cube, with step-by-step instructions. Consult these only if you're stuck. They may give you some ideas on alternative strategies:

Materials and Equipment

To do this experiment you will need the following materials and equipment:

Experimental Procedure

  1. Do your background research so that you are familiar with the terms, concepts, and questions, above.
  2. If you can already solve Rubik's cube before doing this project, your first step should be to measure your average solution time. Time yourself for each of 5–10 trials, and calculate your average solution time. The cube should be well-randomized for each trial.
  3. Study the three sets of moves covered in the Introduction.
  4. Practice using each set of moves on your Rubik's cube.
    1. Verify that each sequence works as described.
    2. Become familiar enough with each set of moves so that you can step through the sequence in your imagination, without having the cube in your hands or within sight.
  5. Figure out a logical sequence for applying these three sets of moves in order to solve the cube systematically. In other words, use the three sets of moves as the basis for developing an algorithm to solve Rubik's cube.
    1. During this step, it is important to determine whether the three move sequences presented in the Introduction are sufficient to solve the cube. In other words, is it possible to solve the cube with only these three move sequences, or do you need additional move sequences?
    2. If you determine that additional move sequences are needed, be prepared to show why they are needed. Develop one or more move sequences to fill in the missing rearrangements needed to solve the cube.
  6. Once you have developed your algorithm, time yourself for 10 or more trials and see how long it takes you, on average, to solve the puzzle. The cube should be well randomized for each trial.
  7. If you could solve the puzzle before you started the project, did your average solution time improve?
icon scientific method

Ask an Expert

Do you have specific questions about your science project? Our team of volunteer scientists can help. Our Experts won't do the work for you, but they will make suggestions, offer guidance, and help you troubleshoot.

Global Connections

The United Nations Sustainable Development Goals (UNSDGs) are a blueprint to achieve a better and more sustainable future for all.

This project explores topics key to Industry, Innovation and Infrastructure: Build resilient infrastructure, promote sustainable industrialization and foster innovation.

Variations

  • For a more basic Rubik's cube experiment, see the Science Buddies project, What's the Fastest Way to Solve Rubik's Cube?
  • Can naive Rubik's cube players use your algorithm to solve the puzzle? Find volunteers with no experience solving Rubik's cube. See if they can solve the puzzle on their own. Record how long it takes them to solve the puzzle, or to give up. Teach them your algorithm, give them some time to practice it, and time them again. Do this for at least five volunteers. Did their solution times improve? By how much, on average?
  • Advanced. Are there even faster ways to solve Rubik's cube? Practice on your own, or do some investigation online. How much can you improve your average solution time?
  • Advanced. If you have skills in computer programming, learn how to use the Java applet to demonstrate how your algorithm works. The Java applet used to illustrate the moves in this project was written by Karl Hšrnell, Lars Petrus, and Matthew Smith. It can be obtained from: http://lar5.com/cube/downloads.html.

Careers

If you like this project, you might enjoy exploring these related careers:

Career Profile
You've probably heard the expression "build a better mousetrap." Industrial engineers are the people who figure out how to do things better. They find ways that are smarter, faster, safer, and easier, so that companies become more efficient, productive, and profitable, and employees have work environments that are safer and more rewarding. You might think from their name that industrial engineers just work for big manufacturing companies, but they are employed in a wide range of industries,… Read more
Career Profile
Are you interested in developing cool video game software for computers? Would you like to learn how to make software run faster and more reliably on different kinds of computers and operating systems? Do you like to apply your computer science skills to solve problems? If so, then you might be interested in the career of a computer software engineer. Read more

News Feed on This Topic

 
, ,

Cite This Page

General citation information is provided here. Be sure to check the formatting, including capitalization, for the method you are using and update your citation, as needed.

MLA Style

Science Buddies Staff. "Devising an Algorithm for Solving Rubik's Cube." Science Buddies, 20 Nov. 2020, https://www.sciencebuddies.org/science-fair-projects/project-ideas/Math_p025/pure-mathematics/algorithms-for-solving-rubiks-cube. Accessed 19 Mar. 2024.

APA Style

Science Buddies Staff. (2020, November 20). Devising an Algorithm for Solving Rubik's Cube. Retrieved from https://www.sciencebuddies.org/science-fair-projects/project-ideas/Math_p025/pure-mathematics/algorithms-for-solving-rubiks-cube


Last edit date: 2020-11-20
Top
We use cookies and those of third party providers to deliver the best possible web experience and to compile statistics.
By continuing and using the site, including the landing page, you agree to our Privacy Policy and Terms of Use.
OK, got it
Free science fair projects.