How to solve a Rubik's cube by using algorithms

Never solved a Rubik's cube? Want to? Then follow this rough and ready guide to join the ranks of millions of people worldwide who have.
Christopher McFadden
Hands solving a Rubik's Cube
Hands solving a Rubik's Cube


  • First developed in the 1970s, the Rubik's Cube is one of the most popular mind puzzles worldwide.
  • But, for most people, it can be very intimidating to attempt to solve.
  • However, by using some basic algorithms, the Rubik's cube isn't really that tricky to solve.

Love it or hate it, The Rubik's cube is one of the world's most popular puzzles. It is an intimidating challenge for many, but it doesn't need to be.

With a few simple algorithms and some perseverance, you, too, can solve one in short order, even if you haven't before. 

Read on to find out how.  

How long does it take the average person to solve a Rubik's Cube?

If you have trouble solving a Rubik's cube, don't fret, you are not alone. In fact, according to some estimates, only 6% of the population has ever achieved it. Either through a combination of learning algorithms (more on that later), or sheer determination, solving a Rubik's cube can certainly be done if you are willing to work at it. 

In fact, it took the inventor of the Rubik's cube, Erno Rubik, one month to learn how to solve his creation.

How to solve a Rubik's cube by using algorithms
Intimidating for many, but exciting for others, the Rubik's cube is a great way to work your grey matter. Source: Rolf Venema/Flickr

The best way to learn how to solve one, without spending hours and days trying to work it out for yourself, is to follow some guides or tutorials. Rest assured, this is not cheating. 

Consider this, a standard 3 by 3 by 3 Rubik's cube has more than 43 quintillion possible combinations, but only a single correct solution. It would take you a very long time to attempt to solve it through brute force alone. 

You need to know some strategies, technically called algorithms, to shortcut the process. This is the very reason that algorithms exist in the first place.

Some of those who have gone through the grinder and learned these algorithms, or set moves, can solve a Rubik's cube in double-quick time. According to some, it should take around 45 minutes or so, on average, to learn these moves. 

It took an artificial intelligence 44 hours to manage the same feat, so bare that in mind.

Once they become muscle memory, you can trim the process of solving a cube significantly. In many cases, according to some sources, it should be possible for the average person to complete a Rubik's cube in around 20 to 25 minutes. 

How to solve a Rubik's cube by using algorithms
The current world record holder for solving the Rubik's cube is Yusheng Du who solved a standard cube in 3.47 seconds. Source: Ruwix

Of course, there are those exceptional people who can solve a cube in less than a minute. The world record for a single solve for the standard 3 by 3 by 3 cube is 3.47 seconds. Yusheng Du, from China, managed this incredible feat in 2018. 

But try not to compare yourself to this fantastic record. Du had been practicing the process for many, many years. 

Can you solve a 3x3 Rubik's cube using algorithms?

In short, yes.

The methods you will use, on the grand and micro-scale, will involve following some set procedures, aka algorithms, to complete the cube. This is essentially what algorithms exist to do. 

You can think of these as set steps to solving a Rubik's cube.

So, are you ready to join the 6% who have solved the Rubik's cube? Brace yourself and enjoy the process...

1. First things first, learn your cube

The first thing to do is to become accustomed to your cube. This guide will focus on the standard 3 by 3 by 3 cube.

Remember, however, that the following procedures will also apply to other kinds of Rubik's cubes. 

A standard cube consists of six faces (obviously), each consisting of one of six different colors. The middle pieces of each face are fixed, and all other axes (x, y, and z) can rotate clockwise and counterclockwise.

How to solve a Rubik's cube by using algorithms
Modifed from Rolf Venema/Flickr

Guides will usually refer to blocks as consisting of edge pieces (the middle block on the moving edges -- there are twelve of these), corner pieces (the eight corners of the cube), and centerpieces (which are the six fixed bits). 

The colored sides on a standard cube are always paired in the same way.

This is important to understand and is essential for solving the cube. Based on these color pairings, you will aim to move pieces into their correct final position.

In the following guide and others, we will refer to certain moves when revealing algorithms for solving the cube. These are standard nomenclature, and they are as follows (courtesy of The Official Rubik's Cube Site): 

How to solve a Rubik's cube by using algorithms
Letters donate: front face (F), right column (R), left column (L), upper row (U), down or bottom row (D), etc. These terms are relative to the side of the cube facing you. Always keep the cube in this position when performing algorithms, and never rotate the cube unless instructed. Source: Rubik's Cube

Note the use of the letter "i" on some moves. This means that a move is 'inverted' or reversed.

You will also see greyed-out squares on most images. This just means the block is not in its correct place, and its color on the cube does not matter. 

All moves are a 1/4 rotation. 

For all algorithms provided, it is essential to try and visualize the block moving around and why the move is being made. In most cases, the algorithm will be an even number of moves, to first move the piece and then "repair" the locations of any solved pieces in the rest of the cube (except the first stage and especially the last stage).

Ok, got that? Let's solve the Rubik's cube, shall we?

2. See the bigger picture

At all times, bear in mind the bigger picture. Solving a Rubik's cube essentially follows a master plan.

While the above sounds simple in theory, the process requires you to know a few "tricks" to achieve it. These are essentially little sub-algorithms used to manipulate the pieces into place. 

We'll dedicate the rest of this article to showing you these algorithms to complete the above "master plan" algorithm. 

3. Stage 1 - "The White Cross"

How to solve a Rubik's cube by using algorithms
The "white cross". Remember grey squares are not important here. Note the matching edge pieces to center-pieces. Source: Rubik's Cube

Before we begin, time for a confession.

Most of this guide will borrow heavily from the Rubik's cube official guide and the amazing guide from The author also only recently learned how to solve a Rubik's cube, and if I can do it, so can you!

On with the guide, and good luck.

As previously mentioned, the first thing to do is pick one side to solve. The convention is to use the white side on a standard cube, but it doesn't matter.

How to solve a Rubik's cube by using algorithms
We'll go through a real-life solution along with the guide. Here is the starting state of ours. Luckily one of the edge pieces (the red-white piece) is already in place and just needs to be turned to the left 90 degrees. Source: Interesting engineering

However, if one side has some added detail, like a decal or images, you might want to solve this one first, as doing it later can add unnecessary complications. 

The aim is to produce a cross, usually called the "white cross." Since this is the most straightforward stage, it is highly recommended that you attempt this through trial and error.

Once you've mastered this, you will also use many of the same moves to solve the middle layer.

First, move the white side to the top of the cube. For most of the process, the "top" layer will be your "working" layer, where you move pieces around and then "drop" them into the lower layers, except this stage and the final stage (as they are the "top"). 

Most Popular

Move each edge piece to the top row and then move them to match the white on top and the color on a particular side. It would be best if you learned how to do this intuitively, as a cube's starting "state" will vary widely. 

If you need some help with those pieces that are in the top row but not appropriately orientated, you can flip them using the following sequence: - 

How to solve a Rubik's cube by using algorithms
To rotate an edge piece (left image), following the middle sequence. Note: Ri (right column down), U (top layer to the left), Fi (front face counterclockwise), Ui (top layer to the left). Your goal is to make the cross on the right. Source: Rubik's Cube

Rinse and repeat for all other edge pieces. Once your cube looks like the image on the right above, move to the next stage. 

Below is a worked example of moving one edge piece into place. The exact location and method needed for yours will vary.

Remember, we have greyed-out blocks where the exact color is not essential on your cube. 

How to solve a Rubik's cube by using algorithms
In this example, we can solve two pieces in one algorithm (on the left is the starting condition, on the right the result). Note the cube has been turned 90 degrees to the left in the righthand image. Make sure the red centerpiece is facing you when performing moves (indicated by the red arrow).

1. Rotate the upper level to the left (U) to move the red edge piece above the red centerpiece. 2. Rotate the upper level again (U), and then move the front face counterclockwise (Fi). You will need to also move the top row to the right (Ui) to align both red and blue edges with their correct centerpieces.

Source: Interesting engineering

Keep moving the edge pieces into their correct places until you have the "White Cross." You can refer to the other guides if you need help with some pieces, but we stress that you should try to solve this independently. 

When you have the white cross, move to the next stage, but only if the edge pieces are in the correct order (i.e., match the fixed centerpieces on each side). 

How to solve a Rubik's cube by using algorithms
The "White Cross". Source: Interesting Engineering

4. Stage 2 - Solving the top corners

Next is to finish off the white side with the corner pieces in the right places. While it might not sound tricky, it requires a little thought and practice.

Below is an example of getting one into place from our real example.

How to solve a Rubik's cube by using algorithms
An example of solving a corner piece. Orange is the front face in this example. You are effectively moving the white-orange-green corner piece into place, fixing it in place at the back of the cube, restoring the position of the front face, and bringing the new complete white-orange-green-red row into place. Notice the complete white face and "T" shapes on the sides. Source: Interesting engineering

If you are struggling with other scenarios, check out any of the full tutorials we have provided above to help you out. But, again, we recommend plugging away yourself to solve this stage. 

Once complete, turn the cube over so the white face is on the bottom. You will not be touching it for the next stage. 

5. Stage 3 - Solving the middle layer

This stage is relatively simple, and you only need to know a couple of set moves or algorithms. In most cases, you will shuffle the middle-layer edges from the top layer to the left or right on the middle layer. 

In all cases below, ensure you have orientated the piece so that it is above its matching centerpiece on the side of the cube. E.g., if the color facing you is red, make sure you move the top row until the correct edge piece is above the red center piece facing you. 

Remember, when completing these algorithms, keep the front face in front of you and never move the cube as a whole. Think of this as a cardinal rule!

Here is how you move one piece to the right. We'll dub this the "move-to-the-right" algorithm. 

How to solve a Rubik's cube by using algorithms
Algorithm to move the red-blue middle piece on the top row to its rightful place in the middle/second row. Here the front face is the blue side. Note the first four moves put the piece into place and the last four restore the base. Source: Interesting Engineering

If you need to move it to the left, here is how you do that. We'll call it the "move-to-the-left" algorithm. 

How to solve a Rubik's cube by using algorithms
Algorithm to move the orange-blue middle piece on the top row to its place on the left-hand side in the middle/second row. Here the front face is the blue side. Note the first four moves put the piece into place and the last four restore the base. Source: Interesting Engineering

Sometimes you may need to move a misaligned middle or second-layer edge piece to the top and then back down again. Here is how you make that move.

How to solve a Rubik's cube by using algorithms
Notice that this is the same move as the moving-to-the-right algorithm above. Once in place on the top row, simply rotate the top row to the right (to match green to green). Now make the green face your front face, and complete the "move-to-the-left" algorithm above to put the same piece into the second row. Source: Interesting Engineering.

With the middle, or second, row complete, it is time for the most complicated part -- the top layer. Well done, you are 66% of the way there.

6. Stage 4 - Making the "Yellow Cross"

Now for the top row. First, we must create a cross again, as we did at the beginning. This will be slightly more complex than the "White Cross", as you can imagine. 

For this stage, don't obsess over getting yellow edge pieces in the correct order. Our goal is to simply get the yellow side of each edge piece facing upwards. 

You can skip this stage if you are lucky enough to have a complete cross already. If not, you will need to perform a single algorithm multiple times until you reach the end goal. 

And here it is, courtesy of the makers of this fantastic puzzle...

How to solve a Rubik's cube by using algorithms
Source: Rubik's Cube

When you reach any of the stages above, ensure you turn the upper layer to match its orientation. Again, don't fret about the side colors just yet. 

With the "Yellow Cross" complete, it is time to get those top-edge pieces in their proper places...

7. Stage 5 - If needed, move the "Yellow Cross" edge pieces into the right order

If, by chance, the edge pieces from stage 4 are already in the correct order, skip to stage 6 below.

If not, you will need to perform more moves to get them into their proper places. You can swap them around by performing the following algorithm.

In all cases, ensure you orientate the top row so that at least one of the pieces will end up on the correct side of the cube. Rotate the upper row to get the edge pieces you need to be aligned with the sides they need to move to. 

How to solve a Rubik's cube by using algorithms
If you need to move the edge pieces around on the upper/top row, perform this algorithm. In this example, the red side is your front face. You may need to do this a few times to get all edge pieces in their correct places.  Source: Interesting Engineering

With the edge pieces now appropriately aligned, it is time to deal with those pesky top corners. 

8. S 6 - Orientating the top corners properly

With only four pieces left to move, you might think the worst is behind you. Don't get cocky, this is the stage that usually foxes most novices. 

The first thing to do is to get them into the right spot. Don't concern yourself with their orientation just yet. 

Find a piece already in the right place (its three sides match the surrounding colors on the cube's edge). You may need to move the upper row to find one. 

Orientate the cube so that this corner piece is in the top right of your front face. Then perform the following algorithm to cycle the corner pieces around. 

How to solve a Rubik's cube by using algorithms
Algorithm to cycle corner pieces around. You will likely need to do this a few times until all corners are in place. Don't worry about getting the yellow sides up, just yet. Source: Interesting Engineering

You will likely need to do this a few times, keeping the same reference corner piece in the top right -- it will return to the same position when the algorithm is complete. 

If none exists, perform the same algorithm until one appears, then rinse and repeat.

9. Stage 7 - Finish the cube!

With all the corner pieces in their correct positions, the final and the most fun stage is to orient them correctly, aka get those yellow sides facing upwards. The algorithm is straightforward for this part, but it often freaks out newer Rubik's cube users. 

At the end of each algorithm sequence, your cube will look completely messed up. Don't worry, trust the process, and your cube will be solved in very short order. 

Hold the cube in your hand and choose one of the corners to start the process. Make sure it is in the correct position (aka the surrounding cube face colors are the same as those, in any order, on the corner piece). 

Now perform the following algorithm until the piece is orientated correctly. You will usually need to do this two or four times. 

How to solve a Rubik's cube by using algorithms
Algorithm to correctly orientate a top row corner piece. You will need to repeat this between two and four times until correctly orientated. Source: Interesting Engineering

If you need to do the same for any other corners, keep the same side facing you as before (this is critically important); rotate the upper row to move the piece to the top right, and repeat the procedure two to four times. Rinse and repeat for all other corners. 

We have to stress once again: trust the process. The rest of your cube will appear completely messed up, but it will all come together in the end. 

With the top row solved, simply move to the left or right to complete the cube.

Congratulations, you did it!

Now that you know how to solve the standard 3 by 3 by 3 Rubik's cube, you can practice until you get the processing speed down to impressive levels. Who knows? You may become the next Guinness World Record holder. 

One has to dream...

How do you solve a 2x2 Rubik's cube?

Before we get into some finer details, let us let you in on a little secret. Most of the basic algorithms you've already learned and perhaps mastered can be applied to prealmosttty much any interaction of a Rubik's cube, including the 2 by 2 (aka "pocket cube").

How to solve a Rubik's cube by using algorithms
A typical "pocket cube".

You'll once again need to follow most of the significant steps above that primarily focus on positioning and orientating the "corners." If you bare this in mind, cubes like the 2 by 2 by 2 aren't that intimidating.

Most Rubik's cubers consider the "pocket cube" as one of the simplest to solve.

The only potential hangup is that there are no "fixed" centers to guide you for each face. So, in theory, you can make up your pattern if you want. However, it is advisable to replicate a traditional 3x3 cubes face pattern (e.g., white bottom, yellow top, blue opposite green, and red opposite orange).

Of course, if the colored faces vary on your particular cube, try to take note of the correct order before mixing up the cube and attempting to solve it.

With all that in hand, solve the two layers similarly to a traditional cube, except having to deal with the center and edge pieces.

So, once you've mixed up the cube "blind" or got someone else to prepare it for you, you'll be astonished at how transferable your 3 by 3 Rubik cube skills are to other cubes.

Providing a complete in-depth guide on solving the "pocket cube" is out of the scope of this guide, but make sure you are familiar with the Rubik's cube move notations before following any step-by-step guides. Remember that there are no "middle layer moves" for the 2x2 cube, so the notations are the same (same faces, letters, cube rotations, etc.).

With that in mind, here is a great little guide to solving the 2 by 2 Rubik's cube. However, we thoroughly recommend you attempt to decipher it on your own!

How do you solve a 4x4 Rubik's cube?

The 2 by 2 might be one of the simplest to solve, but the 4 by 4 cube (aka "Rubik's Revenge" is often quite intimidating to Rubik's cube novices. But you shouldn't fret; it is just a larger, slightly more complex version of the classic cube.

Again, like the "pocket cube," the 4 by 4 cube can readily be solved using the same process as a standard cube. However, this advice does come with a caveat; the 4 by 4 cube has more rotation axes and no fixed centerpieces. You'll often need to "build" the centerpieces before aligning them.

This shouldn't be seen as an impossible task; it just adds some extra steps to your solution. You will also need to match up the edge pieces. This is called the "reduction method" and requires us to effectively convert the 4 by 4 into a slightly distorted 3 by 3 cube.

Also, remember you will often need to move two neighboring parallel rows together instead of single rows like in the regular cube. This move is usually notated using one capital letter followed by a lowercase letter.

Some algorithms require one of the inner rows to be moved on its own. This is called an "inner slice" and can take a little practice to execute correctly. This is notated using a lowercase letter on most occasions.

How to solve a Rubik's cube by using algorithms
There are some extra types of move you'll need to know to solve the 4 by 4.

These are really the only extra steps you need to take. With both of these steps done, you should then be able to solve the entire cube like a regular 3 by 3.

But are there any algorithms for the extra steps? Well, yes, there are. We'll discuss those in a little detail now.

Matching the centerpieces on a 4 by 4

Like the regular 3 by 3 cube, we'll start with the white face. Find the four pieces that make up the center and start by matching two of them to make a bar. With that done, match the other two somewhere else on the cube.

With both bars complete, you should experiment to match the two together to make the entire 2 by 2 center. With that done, rinse and repeat for the other sides.

Remember that it is crucial to place the centers in the appropriate places when solving the centers. The white centers belong opposite yellow, the blue centers opposite green, and the red centers opposite orange on a cube with the traditional color scheme. There are two ways to do this, so we also need to consider that.

You will need to intuit how to do this, but here are some helpful tips if you are struggling.

Forming a single bar shouldn't be too taxing, but making and matching two bars can be tricky for beginners. In this case, try to form a little "L" shape and align the last cube on an adjacent face.

Align the last cube in the position you need to turn the "L" into a complete 2 by 2 square. With that done, you can then use the algorithm:-

1. Bottom two rows anticlockwise (Dw')

2. Right two rows anticlockwise (Rw')

3. Bottom two rows clockwise (Rw)

This should then complete a single centerpiece of one face. Rinse and repeat for all other faces.

Matching the edges on a 4 by 4

In the second step of the "Reduction Method," the aim is to match edge pieces. Note that there will be two edge pieces with those same colors for every combination of two colors on the cube (excluding opposites).

To do this, we will need to turn the outside faces of the cube so that we can put the two edge pieces in the front left and front right slots, making sure they are on different layers. Then, we temporarily break up our solved centers to match up these edge pieces and move the now-solved edge pair into the top layer.

We must be careful not to mess up our centers when moving them to the top layer. The following moves:-

  • R (right clockwise)
  • U (upper clockwise)
  • R' (right anticlockwise)
  • R (right clockwise)
  • U' (upper anticlockwise)
  • R' (right anticlockwise)

will move an edge from the front right slot to the top layer.

Keep doing this until all the edges are matched up. This should be relatively straightforward for most edges except the last two.

This is usually the step that infuriates most "Rubik's Revenge" owners, often leading them to want to smash the thing into a million pieces.

How to solve a Rubik's cube by using algorithms
The 4 by 4 "Rubiks Revenge" isn't that scary really.

If you only have two edges left to solve, you can use the following algorithm:-

  • Uw' (Upper two rows anticlockwise)
  • R (right clockwise)
  • U (upper row clockwise)
  • R' (right anticlockwise)
  • F (front clockwise)
  • R' (right anticlockwise)
  • F' (front anticlockwise)
  • R (right clockwise)
  • Uw (Upper two rows clockwise)

If you executed this algorithm correctly, you should "just" have the corners left to solve. This can be done using any of the regular corner-matching algorithms for the standard cube.

Good luck!

What are the fastest algorithms to solve Rubik's Cube?

If you are confident with solving a Rubik's cube the more traditional way and have hit the ceiling with the time it takes you to solve it, then you've reached a level to attempt to learn some faster algorithms.

Learning these is not only incredibly satisfying for your ego but is also a very impressive party trick. You are bound to make loads of new friends (and some envious enemies).

The key to speed is reducing the number of moves needed in the first place. For this reason, when talking about the 3 by 3 cube, the "CFOP Method" is one of the fastest algorithms or methods.

The CFOP (Cross, First 2 layers, Orientation of the last layer, Permutation of the last layer), often known as the "Fridrich Method," is the most widely used speedsolving technique. In contrast to the beginner's method, the speedsolving method focuses more on finding the quickest solution to the Rubik's cube rather than the simplest one.

An entire solution using the CFOP approach typically requires 56 moves. To put that into perspective, the average number of moves while employing the beginner's method is approximately 110.

That's a massive 50 percent reduction in moves (and time) needed — not too shabby!

Today's top speedcubers typically employ the CFOP technique (sometimes with additional variations), so you are in good company if you master this technique.

The speedsolving approach takes a little longer to master than the beginner's method because it involves learning new algorithms and practicing these until they become second nature. However, once fully learned, you'll be able to speed up solving a Rubik's cube considerably more quickly. Only practice will stand between you and the world record from there, with head-turning solve times!

It is typically advised only to begin learning the speedsolving method after completing the beginner's method and successfully solving the Rubik's cube.

You should only try to learn this method if you can solve the Rubik's cube in under two minutes. If you can't, you might be too inexperienced before then.

An in-depth guide to using the "Fridrich Method" is out of the scope of this guide, but the basic main steps are as follows:

  • Cross: Completely resolving the first layer of 4 edge pieces. (what appears to be a cross)
  • F2L: Completely solving the first two layers (not as tricky as it sounds)
  • Correctly orienting the last layer's corner and edge pieces is known as OLL (Orientation of Last Layer).
  • The last layer's corner and edge pieces should be correctly permuted (PLL).

Before learning the speedsolving solution method, it is advised that you get yourself a good, well-turned Rubik's cube because it makes learning new algorithms more straightforward and more enjoyable. Nothing is worse than a "sticky" cube for throwing you off.

Trust us, this is really important. The same is true for pretty much all Rubik's cube "species."

How to solve a Rubik's cube by using algorithms
Speedsolving a Rubik's cube is a great parlour trick.

Like all Rubik's cubes, make sure you intimately understand the mechanics of the puzzle, such as what the edge, corner, and centerpieces are, as well as move notations and other terminology. For speedsolving (more than "beginner methods"), it's crucial to understand the complete move notations (including middle layer turns, double layer turns, and cube rotations).

Like anything in life, you'll be relatively slow to start, but practice can and will make perfect!

And that's your lot for today.

The Rubik's cube is often seen as a challenging puzzle. But, as you've found out, gaining an understanding of the mechanics of the cube, and learning some set moves, can break down solving it into some simple steps.

Once you've mastered the basics, permutation of the basic cube shouldn't be much more work for you. Once you are confident in your abilities, you'll find yourself hunting for ever more complex ones to solve. Avoid the Pentamix; it is considered the most complex variant and should only be attempted by the most patient.

Most importantly, make sure you have some fun, the Rubik's cube is supposed to be a toy, not an exam.

message circleSHOW COMMENT (1)chevron