Optimal solutions for the Rubik's Cube are solutions that are the shortest in some sense. There are two common ways to measure the length of a solution. The first is to count the number of quarter turns. The second is to count the number of outer-layer twists, called "face turns". A move to turn an outer layer two quarter (90°) turns in the same direction would be counted as two moves in the quarter turn metric (QTM), but as one turn in the face metric (FTM, or HTM "Half Turn Metric"). [1]
The maximal number of face turns needed to solve any instance of the Rubik's Cube is 20, [2] and the maximal number of quarter turns is 26. [3] These numbers are also the diameters of the corresponding Cayley graphs of the Rubik's Cube group. In STM (slice turn metric), the minimal number of turns is unknown.
There are many algorithms to solve scrambled Rubik's Cubes. An algorithm that solves a cube in the minimum number of moves is known as God's algorithm.
A randomly scrambled Rubik's Cube will most likely be optimally solvable in 18 moves (~ 67.0%), 17 moves (~ 26.7%), 19 moves (~ 3.4%) or 16 moves (~ 2.6%) in HTM. [4] By the same token, it is estimated that there is only 1 configuration which needs 20 moves to be solved optimally in almost 90×109, or 90 billion, random scrambles. The exact number of configurations requiring 20 optimal moves to solve the cube is still unknown.
To denote a sequence of moves on the 3×3×3 Rubik's Cube, this article uses "Singmaster notation", [5] which was developed by David Singmaster.
The following are standard moves, which do not move centre cubies of any face to another location:
The letters L, R, F, B, U, and D indicate a clockwise quarter turn of the left, right, front, back, up, and down face respectively. A half turn (i.e. 2 quarter turns in the same direction) are indicated by appending a 2. A counterclockwise turn is indicated by appending a prime symbol ( ' ).
It can be proven by counting arguments that there exist positions needing at least 18 moves to solve. To show this, first count the number of cube positions that exist in total, then count the number of positions achievable using at most 17 moves starting from a solved cube. It turns out that the latter number is smaller.
This argument was not improved upon for many years. Also, it is not a constructive proof: it does not exhibit a concrete position that needs this many moves. It was conjectured that the so-called superflip would be a position that is very difficult. A Rubik's Cube is in the superflip pattern when each corner piece is in the correct position, but each edge piece is incorrectly oriented. [6] In 1992, a solution for the superflip with 20 face turns was found by Dik T. Winter, of which the minimality was shown in 1995 by Michael Reid, providing a new lower bound for the diameter of the cube group. Also in 1995, a solution for superflip in 24 quarter turns was found by Michael Reid, with its minimality proven by Jerry Bryan. [6] In 1998, a new position requiring more than 24 quarter turns to solve was found. The position, which was called a 'superflip composed with four spot' needs 26 quarter turns. [7]
The first upper bounds were based on the 'human' algorithms. By combining the worst-case scenarios for each part of these algorithms, the typical upper bound was found to be around 100.
Perhaps the first concrete value for an upper bound was the 277 moves mentioned by David Singmaster in early 1979. He simply counted the maximum number of moves required by his cube-solving algorithm. [8] [9] Later, Singmaster reported that Elwyn Berlekamp, John Conway, and Richard K. Guy had come up with a different algorithm that took at most 160 moves. [8] [10] Soon after, Conway's Cambridge Cubists reported that the cube could be restored in at most 94 moves. [8] [11]
Four computer algorithms (three of which can find an optimal Rubik's Cube solution in the half-turn metric) are described below. An animated example solve has been made for each of them. The scrambling move sequence used in all example solves is: U2 B2 R' F2 R' U2 L2 B2 R' B2 R2 U2 B2 U' L R2 U L F D2 R' F'. Use the buttons at the top right to navigate through the solves, then use the button bar at the bottom to play the solving sequence. Example solves.
The breakthrough, known as "descent through nested sub-groups" was found by Morwen Thistlethwaite; details of Thistlethwaite's algorithm were published in Scientific American in 1981 by Douglas Hofstadter. The approaches to the cube that led to algorithms with very few moves are based on group theory and on extensive computer searches. Thistlethwaite's idea was to divide the problem into subproblems. Where algorithms up to that point divided the problem by looking at the parts of the cube that should remain fixed, he divided it by restricting the type of moves that could be executed. In particular he divided the cube group into the following chain of subgroups:
Next he prepared tables for each of the right coset spaces . For each element he found a sequence of moves that took it to the next smaller group. After these preparations he worked as follows. A random cube is in the general cube group . Next he found this element in the right coset space . He applied the corresponding process to the cube. This took it to a cube in . Next he looked up a process that takes the cube to , next to and finally to .
Although the whole cube group is very large (~4.3×1019), the right coset spaces and are much smaller. The coset space is the largest and contains only 1082565 elements. The number of moves required by this algorithm is the sum of the largest process in each step.
Initially, Thistlethwaite showed that any configuration could be solved in at most 85 moves using a totally different method. In January 1980 he improved his strategy to yield a maximum of 80 moves. Later that same year, he reduced the number to 63 using a new approach, and then again to 52 using an entirely different approach which is now known as Thistlethwaite's algorithm. [12] By exhaustively searching the coset spaces it was later found that the worst possible number of moves for each stage was 7, 10, 13, and 15 giving a total of 45 moves at most. There have been implementations of Thistlewaite's algorithm in various computer languages.
Thistlethwaite's algorithm was improved by Herbert Kociemba in 1992. He reduced the number of intermediate groups to only two:
Kociemba's two-phase algorithm is not designed to search for an optimal solution, its purpose is to quickly find a reasonably short suboptimal solution. A randomly scrambled cube would be typically solved in a fraction of a second in 20 moves or less, but without any guarantee that the solution found is optimal. While it is technically possible to search for an optimal solution using Kociemba's algorithm by reducing a two-phase solver to only a one-phase solver (only phase 1 would be used until the cube is completely solved, no phase 2 operation being done at all), more hardware utilization would be neccessary in that case because a fast optimal solver requires significantly more computing resources than a fast suboptimal solver.
As with Thistlethwaite's algorithm, he would search through the right coset space to take the cube to group . Next he searched the optimal solution for group . The searches in and were both done with a method equivalent to iterative deepening A* (IDA*). The search in needs at most 12 moves and the search in at most 18 moves, as Michael Reid showed in 1995. By also generating suboptimal solutions that take the cube to group and looking for short solutions in , much shorter overall solutions are usually obtained.
In 1995 Michael Reid proved that using these two groups every position can be solved in at most 29 face turns, or in 42 quarter turns. This result was improved by Silviu Radu in 2005 to 40.
At first glance, this algorithm appears to be practically inefficient: if contains 18 possible moves (each move, its prime, and its 180-degree rotation), that leaves (over 1 quadrillion) cube states to be searched. Even with a heuristic-based computer algorithm like IDA*, which may narrow it down considerably, searching through that many states is likely not practical. To solve this problem, Kociemba devised a lookup table that provides an exact heuristic for . [13] When the exact number of moves needed to reach is available, the search for suboptimal solutions becomes virtually instantaneous (note that the search for optimal solution takes much longer time): one need only generate 18 cube states for each of the 12 moves and choose the one with the lowest heuristic each time. This allows the second heuristic, that for , to be less precise and still allow for a solution to be computed in reasonable time on a modern computer.
Using these group solutions combined with computer searches will generally quickly give very short solutions. But these solutions do not always come with a guarantee of their minimality. To search specifically for minimal solutions a new approach was needed.
In 1997 Richard Korf announced an algorithm with which he had optimally solved random instances of the cube. Of the ten random cubes he did, none required more than 18 face turns. The method he used is called IDA* and is described in his paper "Finding Optimal Solutions to Rubik's Cube Using Pattern Databases". [14] Korf describes this method as follows
It works roughly as follows. First he identified a number of subproblems that are small enough to be solved optimally. He used:
Clearly the number of moves required to solve any of these subproblems is a lower bound for the number of moves needed to solve the entire cube.
Given a random cube C, it is solved as iterative deepening. First all cubes are generated that are the result of applying 1 move to them. That is C * F, C * U, ... Next, from this list, all cubes are generated that are the result of applying two moves. Then three moves and so on. If at any point a cube is found that needs too many moves based on the lower bounds to still be optimal it can be eliminated from the list.
Although this algorithm will always find optimal solution, its search time is considerably longer in comparison with Kociemba's or Feather's algorithm.
In 2006, Silviu Radu further improved his methods to prove that every position can be solved in at most 27 face turns or 35 quarter turns. [15] Daniel Kunkle and Gene Cooperman in 2007 used a supercomputer to show that all unsolved cubes can be solved in no more than 26 moves (in face-turn metric). Instead of attempting to solve each of the billions of variations explicitly, the computer was programmed to bring the cube to one of 15,752 states, each of which could be solved within a few extra moves. All were proved solvable in 29 moves, with most solvable in 26. Those that could not initially be solved in 26 moves were then solved explicitly, and shown that they too could be solved in 26 moves. [16] [17]
Tomas Rokicki reported in a 2008 computational proof that all unsolved cubes could be solved in 25 moves or fewer. [18] This was later reduced to 23 moves. [19] In August 2008, Rokicki announced that he had a proof for 22 moves. [20]
Finally, in 2010, Tomas Rokicki, Herbert Kociemba, Morley Davidson, and John Dethridge gave the final computer-assisted proof that all cube positions could be solved with a maximum of 20 face turns. [2] In 2009, Tomas Rokicki proved that 29 moves in the quarter-turn metric is enough to solve any scrambled cube. [21] And in 2014, Tomas Rokicki and Morley Davidson proved that the maximum number of quarter-turns needed to solve the cube is 26. [3]
The face-turn and quarter-turn metrics differ in the nature of their antipodes. [3] An antipode is a scrambled cube that is maximally far from solved, one that requires the maximum number of moves to solve. In the half-turn metric with a maximum number of 20, there are hundreds of millions of such positions. In the quarter-turn metric, only a single position (and its two rotations) is known that requires the maximum of 26 moves. Despite significant effort, no additional quarter-turn distance-26 positions have been found. Even at distance 25, only two positions (and their rotations) are known to exist. [3] At distance 24, perhaps 150,000 positions exist.
In 2015, Michael Feather introduced a unique two-phase algorithm on his website. It is capable of generating both suboptimal and optimal solutions in reasonable time on a modern device. [22] Unlike Thistlethwaite's or Kociemba's algorithm, Feather's algorithm is not heavily based on the mathematical field of group theory.
The Rubik's Cube can be simplified by using only 3 colors instead of usual 6 colors. Generally, opposite faces would share the same color. On a 6-color cube, a solved 3-color cube would be represented by a state in which only opposite colors appear on opposite faces.
In a nutshell, Feather's algorithm goes like this: any 3-color solutions that arise from the nodes being generated are then looked up in the array containing distances from intermediate 3-color solutions to the final 6-color solution (a total of 3,981,312 configurations), and if it is 8 moves or less (of which there are 117,265 configurations) then a solution is generated. [23] One can think of it as a brute-force search enhanced by using distance arrays to prune the search tree where possible, and also reducing the size of the distance arrays effectively by using cube symmetry. [24]
When searching for an optimal solution, Feather's algorithm is finding suboptimal solutions on the way. This is an advantage because in many cases it does not have to search the depth of the optimal solution length because it has already found a suboptimal solution at a lower depth that is equal to the optimal solution length, hence it only has to complete search depth N-1 to prove that solution length N is optimal.
Feather's algorithm was implemented in the first online optimal Rubik's Cube solver, more specifically in the first client-side processing (JavaScript) solver with a graphical user interface running in a web browser and being able to generate optimal solutions in a timely manner. That includes computing 19-move long optimal solutions as they will occur roughly in a 3.4% of all cases in a batch of randomly scrambled cubes. The solver has multiple options for different size distance arrays to maximize use of available RAM, and it also uses all available processors to get the best performance from a wide variety of platforms. [25]
The Rubik's Cube is a 3D combination puzzle invented in 1974 by Hungarian sculptor and professor of architecture Ernő Rubik. Originally called the Magic Cube, the puzzle was licensed by Rubik to be sold by Pentangle Puzzles in the UK in 1978, and then by Ideal Toy Corp in 1980 via businessman Tibor Laczi and Seven Towns founder Tom Kremer. The cube was released internationally in 1980 and became one of the most recognized icons in popular culture. It won the 1980 German Game of the Year special award for Best Puzzle. As of January 2024, around 500 million cubes had been sold worldwide, making it the world's bestselling puzzle game and bestselling toy. The Rubik's Cube was inducted into the US National Toy Hall of Fame in 2014.
In the theory of computational complexity, the travelling salesman problem (TSP) asks the following question: "Given a list of cities and the distances between each pair of cities, what is the shortest possible route that visits each city exactly once and returns to the origin city?" It is an NP-hard problem in combinatorial optimization, important in theoretical computer science and operations research.
The Rubik's Revenge is a 4×4×4 version of the Rubik's Cube. It was released in 1981. Invented by Péter Sebestény, the cube was nearly called the Sebestény Cube until a somewhat last-minute decision changed the puzzle's name to attract fans of the original Rubik's Cube. Unlike the original puzzle, it has no fixed faces: the center faces are free to move to different positions.
The 15 puzzle is a sliding puzzle. It has 15 square tiles numbered 1 to 15 in a frame that is 4 tile positions high and 4 tile positions wide, with one unoccupied position. Tiles in the same row or column of the open position can be moved by sliding them horizontally or vertically, respectively. The goal of the puzzle is to place the tiles in numerical order.
The Pocket Cube is a 2×2×2 combination puzzle invented in 1970 by American puzzle designer Larry D. Nichols. The cube consists of 8 pieces, which are all corners.
Speedcubing, also referred to as speedsolving, is a competitive mind sport centered around the rapid solving of various combination puzzles. The most prominent puzzle in this category is the 3×3×3 puzzle, commonly known as the Rubik's Cube. Participants in this sport are called "speedcubers", who focus specifically on solving these puzzles at high speeds to get low clock times. The essential aspect of solving these puzzles typically involves executing a series of predefined algorithms in a particular sequence with eidetic prediction and finger tricks.
The Pyraminx is a regular tetrahedron puzzle in the style of Rubik's Cube. It was made and patented by Uwe Mèffert after the original 3 layered Rubik's Cube by Ernő Rubik, and introduced by Tomy Toys of Japan in 1981.
David Breyer Singmaster was an American-British mathematician who was emeritus professor of mathematics at London South Bank University, England. He had a huge personal collection of mechanical puzzles and books of brain teasers. He was most famous for being an early adopter and enthusiastic promoter of the Rubik's Cube. His Notes on Rubik's "Magic Cube" which he began compiling in 1979 provided the first mathematical analysis of the Cube as well as providing one of the first published solutions. The book contained his cube notation which allowed the recording of Rubik's Cube moves, and which quickly became the standard.
The Megaminx or Mégaminx is a dodecahedron-shaped puzzle similar to the Rubik's Cube. It has a total of 50 movable pieces to rearrange, compared to the 20 movable pieces of the Rubik's Cube.
Iterative deepening A* (IDA*) is a graph traversal and path search algorithm that can find the shortest path between a designated start node and any member of a set of goal nodes in a weighted graph. It is a variant of iterative deepening depth-first search that borrows the idea to use a heuristic function to conservatively estimate the remaining cost to get to the goal from the A* search algorithm. Since it is a depth-first search algorithm, its memory usage is lower than in A*, but unlike ordinary iterative deepening search, it concentrates on exploring the most promising nodes and thus does not go to the same depth everywhere in the search tree. Unlike A*, IDA* does not utilize dynamic programming and therefore often ends up exploring the same nodes many times.
The Rubik's Cube group represents the structure of the Rubik's Cube mechanical puzzle. Each element of the set corresponds to a cube move, which is the effect of any sequence of rotations of the cube's faces. With this representation, not only can any cube move be represented, but any position of the cube as well, by detailing the cube moves required to rotate the solved cube into that position. Indeed with the solved position as a starting point, there is a one-to-one correspondence between each of the legal positions of the Rubik's Cube and the elements of . The group operation is the composition of cube moves, corresponding to the result of performing one cube move after another.
God's algorithm is a notion originating in discussions of ways to solve the Rubik's Cube puzzle, but which can also be applied to other combinatorial puzzles and mathematical games. It refers to any algorithm which produces a solution having the fewest possible moves. The allusion to the deity is based on the notion that an omniscient being would know an optimal step from any given configuration.
Morwen Bernard Thistlethwaite is a knot theorist and professor of mathematics for the University of Tennessee in Knoxville. He has made important contributions to both knot theory and Rubik's Cube group theory.
The Rubik's Cube is the original and best known of the three-dimensional sequential move puzzles. There have been many virtual implementations of this puzzle in software. It is a natural extension to create sequential move puzzles in more than three dimensions. Although no such puzzle could ever be physically constructed, the rules of how they operate are quite rigorously defined mathematically and are analogous to the rules found in three-dimensional geometry. Hence, they can be simulated by software. As with the mechanical sequential move puzzles, there are records for solvers, although not yet the same degree of competitive organisation.
The Simple Solution to Rubik's Cube by James G. Nourse is a book that was published in 1981. The book explains how to solve the Rubik's Cube. The book became the best-selling book of 1981, selling 6,680,000 copies that year. It was the fastest-selling title in the 36-year history of Bantam Books.
In graph theory, the metric k-center problem or vertex k-center problem is a classical combinatorial optimization problem studied in theoretical computer science that is NP-hard. Given n cities with specified distances, one wants to build k warehouses in different cities and minimize the maximum distance of a city to a warehouse. In graph theory, this means finding a set of k vertices for which the largest distance of any point to its closest vertex in the k-set is minimum. The vertices must be in a metric space, providing a complete graph that satisfies the triangle inequality. It has application in facility location and clustering.
The original Rubik's cube was a mechanical 3×3×3 cube puzzle invented in 1974 by the Hungarian sculptor and professor of architecture Ernő Rubik. Extensions of the Rubik's cube have been around for a long time and come in both hardware and software forms. The major extension have been the availability of cubes of larger size and the availability of the more complex cubes with marked centres. The properties of Rubik’s family cubes of any size together with some special attention to software cubes is the main focus of this article. Many properties are mathematical in nature and are functions of the cube size variable.
The superflip or 12-flip is a special configuration on a Rubik's Cube, in which all the edge and corner pieces are in the correct permutation, and the eight corners are correctly oriented, but all twelve edges are oriented incorrectly ("flipped").
The Layer by Layer method, also known as the beginners' method, is a method of solving the 3x3x3 Rubik's Cube. Many beginners' methods use this approach, and it also forms the basis of the CFOP speedcubing technique.
The Gear Cube is a 3-D combination puzzle designed and created by Dutch puzzle maker Oskar van Deventer based on an idea by Bram Cohen. It was initially produced by Shapeways in 2009 and known as "Caution Cube" due to the likelihood of getting one's fingers stuck between the gears while speedcubing. Later, in 2010, it was mass-produced by Meffert's as the "Gear Cube".