Abstract 1 Introduction 2 Preliminaries 3 The Relationship Between Diameter and Mean Distance 4 The Demigod Number for the Rubik’s Cube 5 Discussion References Appendix A The Beginner’s Method and the “Human’s Number” Appendix B Proof of Theorem 15

A Demigod’s Number for the Rubik’s Cube

Arturo Merino ORCID Department of Computer Science, University of Chile, Santiago, Chile Bernardo Subercaseaux ORCID Carnegie Mellon University, Pittsburgh, PA, USA
Abstract

It is by now well-known that any state of the 3×3×3 Rubik’s Cube can be solved in at most 20 moves, a result often referred to as “God’s Number”. However, this result took Rokicki et al. around 35 CPU years to prove and is therefore very challenging to reproduce. We provide a novel approach to obtain a worse bound of 36 moves with high confidence, but that offers two main advantages: (i) it is easy to understand, reproduce, and verify, and (ii) our main idea generalizes to bounding the diameter of other vertex-transitive graphs by at most twice its true value, hence the name “demigod number”. Our approach is based on the fact that, for vertex-transitive graphs, the diameter at most twice the average distance (of which we give a much simpler proof than in the literature). Then, by sampling uniformly random states and using a modern solver to obtain upper bounds on their distance, a standard concentration bound allows us to confidently state that the average distance is around 18.32±0.18, from where the diameter is at most 36.

Keywords and phrases:
Diameter, Rubik’s Cube, Experimental mathematics
Funding:
Arturo Merino: supported by ANID FONDECYT Iniciación No 11251528.
Bernardo Subercaseaux: supported by NSF grant DMS-2434625.
Copyright and License:
[Uncaptioned image] © Arturo Merino and Bernardo Subercaseaux; licensed under Creative Commons License CC-BY 4.0
2012 ACM Subject Classification:
Mathematics of computing Paths and connectivity problems
Editor:
John Iacono

1 Introduction

The 3×3×3 Rubik’s Cube, illustrated in Figure 1, is arguably one of the most iconic puzzles ever created, and one of the best-selling toys of all time; its beautiful balance of simplicity (it only has 6 faces, with 54 colored stickers) and complexity (it has over 4.31019 possible states) has captured the attention of millions of people around the world since its invention in 1974. Naturally, such a combinatorially rich puzzle has raised a variety of interesting mathematical questions, with the most famous one being:

What is the minimum number of moves required to solve the Rubik’s Cube from any starting position?

To make this question precise, we consider the half-turn metric, in which turning either of the 6 faces of the cube by any amount (i.e., 90, 180, or 270) counts as a single move. After a series of incremental improvements detailed in Table 1, Rokicki et al. [19] proved that 20 moves are always enough to solve any Rubik’s Cube in the half-turn metric, a result often referred to as “God’s Number”. This result, however, was obtained by a mixture of mathematical ideas and extensive computation, taking around 35 CPU years. As a result, verifying the correctness of the so-called God’s Number is extremely challenging, and the required computations have likely never been reproduced independently. While the result is widely believed to be true, our goal is to provide an alternative approach (providing a weaker bound) that can be easily understood and reproduced in e.g., a classroom setting.

Table 1: Historical bounds on the maximum number of moves required to solve the Rubik’s Cube [17].
Year Lower bound Upper bound
1981 18 52
1990 18 42
1992 18 39
1992 18 37
1995 18 29
1995 20 29
2005 20 28
2006 20 27
2007 20 26
2008 20 25
2008 20 23
2008 20 22
2010 20 20

Summary

Our approach is based on the following observation: in any vertex-transitive graph (i.e., a graph where every vertex “looks the same”), the diameter D (i.e., the maximum distance between any two vertices) is at most twice the mean distance between vertices, m. This observation corresponds to a question posed by Alan Kaplan [21], which was answered in the more general context of homogeneous compact metrics spaces by Herman and Pakianathan [7]. Our proof, however, is elementary and self-contained, and we believe it can be a nice addition to a first course on graph theory.

We apply the previous observation to the Cayley graph of the Rubik’s Cube (defined formally in Section 2, this graph has the possible states of the cube as vertices and edges between pairs of states that are one “move” away from each other) – if we knew the average distance μ between states of the Rubik’s Cube, we could bound its diameter by at most twice this value. While we cannot directly compute the exact value of μ for the Rubik’s Cube111Recall that it has over 41019 many states., we can provide a good estimate by sampling random pairs of states and computing an upper bound on their distance through standard Rubik’s algorithms (i.e., Kociemba’s Two-Phase Algorithm [13]). Each of these upper bounds for the distance between a pair of states is certified by a short sequence of moves, so one can trust the result without needing to trust the solving algorithm itself. Then, through simple concentration bounds, we will argue that the empirical average of μ^18.3189 we obtain is overwhelmingly likely to be a good estimate of the true mean distance μ, and therefore an audience should reasonably trust that the diameter of the Rubik’s Cube is at most 36 (since it must be an integer). As the first step, we will prove the following theorem.

Theorem 1.

Given a state s of the Rubik’s Cube, let d(s) be the distance from s to the solved state. Let S be a set of states of the Rubik’s Cube sampled uniformly at random, and let μ^S=1|S|sSd(s) be the random variable corresponding to the average distance between states in S and the solved state. Then, if D denotes the diameter of the Rubik’s Cube, we have

𝐏𝐫S[D2μ^S+0.36]<exp(|S|648 534).

Note immediately that Theorem 1 implies that if D>36 (and thus D37 since the diameter is an integer), then the probability of obtaining μ^S18.318 for |S|=107 is roughly 2107. However, this experience can be observed repeatedly, which is therefore a great degree of probabilistic evidence for D36. Unfortunately, Theorem 1 is somewhat computationally expensive, as it requires the number of samples |S| to be around 10 million if we desire a probability of error under 107. As we show in Section 4, this would take roughly 100 hours of computation. In order to see how to reduce the required computation, let us briefly discuss how Theorem 1 is obtained. To obtain an upper bound on D, we can leverage the D<2μ observation and look for an upper bound on μ, which we can do with a probabilistic guarantee by considering an empirical average μS. However, a priori it could be that the true average μ is much larger than our empirical estimate μS due to a small number of states that are very far and we are not likely to sample randomly – a “long tail” phenomenon. Our solution to this problem is using a “Human’s number”, which is an unconditional modest upper bound on D. For instance, the so-called “beginner’s method” suffices to obtain an upper bound of 205 moves. A proof sketch is provided in the appendix, but we expect readers familiar with the beginner’s method to find this bound trivial, since it is far from being tight.

Lemma 2 (Human’s Number).

Any position of the Rubik’s Cube can be solved in at most 205 moves.

Thus, in general, our work can be interpreted as a method for transforming a “Human’s number” into a “Demigod number” that is easy to trust and at most twice the real “God’s number”. Now, going back to the problem of how to reduce the number of samples, the 648 534 constant in Theorem 1 is a consequence of the constant 205 in Lemma 2. We can improve on this by showing first that in a large percentage of the cases, we can use an upper bound of 20 instead of 205. Indeed, let us say that a state is “far from being solved” if it requires strictly more than 20 moves to be solved. Naturally, the “God’s number” result corresponds to saying that no state is “far from being solved”, but proving this requires a great computational effort. Instead, we use a much simpler argument: if the proportion of states that are “far from being solved” were to be bigger than, say, 0.03%, then we would certainly expect to see a state that is “far from being solved” after 50 000 random samples. Yet, experimentally we do not see any such state after 500 000 samples, which makes the possibility of more than 0.03% of total states being “far from being solved” extremely slim. This way, we can separate μ into:

[pfars far from being solvedd(s)]+[(1pfar)s not far from being solvedd(s)]

Finally, we believe that our approach can be used as an example to motivate philosophical conversations about plausibility, a notion explored at large by George Polya in his book “Mathematics and Plausible Reasoning” [16]. In a nutshell, the idea is that while certain types of reasoning do not provide full proof of a statement, they can provide a high degree of confidence in its truth [2]. This is the case, for example, with probabilistic primality tests, which may allow us to confidently assert that a number N, with hundreds of millions of digits is prime, without providing a proof in the traditional sense of the word. Then, if we proved in the traditional sense that a certain number-theoretic statement T is true provided N is prime, our confidence in the primality of N should translate into confidence in statement T.

(a) Solved state.
(b) Flat view of the solved state, letters show how we will refer to faces (see Appendix A).
(c) A scrambled state.
Figure 1: Illustration of the 3×3×3 Rubik’s Cube.

2 Preliminaries

Let us introduce the notation and definitions required to work over the Rubik’s cube mathematically. We will see the Rubik’s cube as a group, a standard idea (see e.g., [4, 1]) that we make explicit nonetheless to make our work as self-contained as possible.

Let Sn denote the group of permutations of n elements under the composition operation, denoted by . For example, (2,3,1)S3 is the permutation defined by:

12, 23, 31=(123231),

and thus, for instance,

(2,3,1)(1,3,2)=(2,1,3).

We identify each state of the Rubik’s cube with a permutation of its stickers, of which there are 69=54 (9 per each of the 6 faces), and as moving faces in the Rubik’s cube results in a permutation of its stickers, the Rubik’s cube can be seen as a subgroup of S54, as illustrated in Figure 2.222More in general, a classic theorem of Cayley states that any group is isomorphic to a subgroup of a symmetric group [10, Section 1.3]. Furthermore, as no moves affect the relative position of the center stickers (5,14,23,32,41,50), we can see the Rubik’s cube as a subgroup of S48. To complete the definition of the Rubik’s cube group, we need to define the “moves”, which correspond to the following permutations (omitting the values that are not affected by the move):

R=(36921242728293031333435363740434851544340373693033362935283134545148212427),
L=(14710111213151617181922253942454649521922251215181117101316464952741454239),
U=(1234678910111219202128293037383936928147373839101112192021282930),

and similarly, D, F, and B can be deduced from Figure 2. The moves R’, L’, U’, etc., correspond to the inverse of the moves R, L, U, etc., respectively. A sequence of moves is simply a composition of moves, omitting the composition symbol, e.g., R U2 corresponds to the permutation RUU.

Figure 2: Illustration of the Rubik’s cube as a subgroup of S54 (or even S48 due to the centers being static).

Let , the Rubik’s cube group, be the subgroup of S54 generated by the standard moves, i.e., =R,L,U,D,F,B. As described earlier, is clearly isomorphic to a subgroup of S48 due to the centers of each face being unaffected by the generators. Finally, note that this group perspective blurs the difference between sequences of moves and states of the cube; every move corresponds to a state of the cube (the result of applying the move to the solved state), and every state reachable from the solved state by moves corresponds to an equivalence class of all move sequences reaching that state.

Definition 3 (Cayley Graph).

Given a group G=(A,) and a set of generators SA, the Cayley graph GS is the graph whose vertex set is A and where two vertices u,vG are adjacent if there exists a generator sS such that us=v.

We will use G to denote the Cayley graph of the Rubik’s cube group under the following set of generators:

S:={R,R’,R2,L,L’,L2,U,U’,U2,D,D’,D2,F,F’,F2,B,B’,B2}.

Note that the reason we include e.g., R’ and R2 in S is that we want to count those as single moves of the cube. Counting R2 as 2 moves leads to a different metric, usually called the Quarter-turn Metric, where God’s number is 26 [18].

Definition 4 (Diameter).

The diameter D of a graph G=(V,E) is the maximum distance between any two vertices, where the distance between two vertices u,vV is the length of the shortest path between them. That is,

D=maxu,v(.V2.)d(u,v).

In this language, “God’s number” is simply the diameter of the Rubik’s cube graph G.

Definition 5 (Mean distance).

The mean distance μ of a graph G=(V,E) is the average distance between any two vertices, that is,

μ=1(.|V|2.)u,v(.V2.)d(u,v).
Definition 6 (Graph automorphism).

An automorphism over a graph G=(V,E) is a bijection φ:VV such that for any two vertices u,vV, we have that (u,v)E if and only if (φ(u),φ(v))E.

Using the previous definition repeatedly leads to the following trivial lemma.

Lemma 7.

If φ is an automorphism over a graph G=(V,E), then for any two vertices u,vV, we have that d(u,v)=d(φ(u),φ(v)).

Definition 8 (Vertex Transitivity).

A graph G=(V,E) is vertex-transitive if for any two vertices u,vV, there exists an automorphism φ such that φ(u)=v.

We now state a folklore idea that will be key to our analysis of the Rubik’s cube graph.

Lemma 9.

Every Cayley graph is vertex-transitive, and in particular, the Rubik’s cube graph G is vertex-transitive.

Proof.

Let G=(A,) be a group and SA a set of generators. We must prove that there is an automorphism φ such that φ(u)=v for any two vertices u,vA. Let us define

φ:AA,φ(x)=vu1x.

This definition directly implies φ(u)=v, and φ is clearly bijective since xuv1x is an inverse for φ. It remains to prove that for any two vertices x,yA, we have that (x,y)E if and only if (φ(x),φ(y))E. Where, by definition of the Cayley graph, a pair of vertices (a,b) is in E if there exists a generator sS such that as=b, and equivalently, if a1bS. Now observe that

φ(x)1φ(y) =(vu1x)1(vu1y)
=(x1uv1)(vu1y)
=(x1u)(v1v)(u1y)
=x1(u1u)y=x1y,

from where we conclude by noting that

(x,y)E x1yS
φ(x)1φ(y)S
(φ(x),φ(y))E.

We conclude this section with a simple lemma stating that in a vertex-transitive graph, given that all nodes are “essentially the same”, we can think of the mean distance as the average distance from a fixed node, instead of between all pairs.

Lemma 10.

Let x be any vertex in a vertex-transitive graph G. Then we have μ=vVd(x,v)|V|1.

Proof.

First, note that by definition of mean distance, and using d(u,u)=0, we have

μ=1(.|V|2.)u,v(.V2.)d(u,v)=1|V|(|V|1)uVvVd(u,v).

Because of vertex-transitivity, for any vertex uV, there exists an automorphism φu such that φu(u)=x. Therefore, using Lemma 7, we have

μ=1|V|(|V|1)uVvVd(u,v)=1|V|(|V|1)uVvVd(x,φu(v))

But as φu:VV is a bijection for every u, we have vVd(x,φu(v))=vVd(x,v), and thus

μ=1|V|(|V|1)uVvVd(x,v)=|V||V|(|V|1)vVd(x,v)=vVd(x,v)|V|1.

3 The Relationship Between Diameter and Mean Distance

In this section, we explore the relationship between the diameter and the mean distance of a graph, and show that for vertex-transitive graphs the diameter is at most twice the mean distance. While this result is implied by [7], we offer a more elementary exposition.

First, let us note that in arbitrary graphs, the diameter D can be much larger than the mean distance μ.

Proposition 11 (Folklore, cf. [22]).

For every n, there are graphs on n vertices such that D/μ=Ω(n1/2).

Proof.

We can construct a graph G by taking a clique on n vertices and attaching to it a path on n1/2 vertices, as illustrated in Figure 3.

Figure 3: A graph G with n=9, illustrating the proof of Proposition 11.

The diameter of this graph is D=n1/2+1. Noting that |V|=n+n1/2=Ω(n), the mean distance can be calculated as follows:

μ =1(.|V(G)|2.)u,v(.V(G)2.)d(u,v)
=1Ω(n2)(1O(n2)within clique vertices+O(n1/2)O(n)within path vertices+O(n1/2)nn1/2clique-to-path)
=O(1).

Furthermore, Wu et al. proved that this bound is asymptotically tight, meaning that D/μ=O(n1/2) [22]. It turns out, however, that such a gap between D and μ is not possible in vertex-transitive graphs, where D and μ are always a constant factor away.

Theorem 12.

For any vertex-transitive graph G of diameter D and mean distance μ we have D<2μ.

Proof.

Let u,v be any pair of vertices such that d(u,v)=D, and use Lemma 10 to write

μ=xVd(u,x)|V|1=xVd(v,x)|V|1, (1)

from where

2μ =xVd(u,x)|V|1+xVd(v,x)|V|1
xVd(u,v)|V|1 (Triangle inequality)
=|V|D|V|1>D.

We can see that this is tight by considering a cycle on 2n vertices, where D=n and using Lemma 10,

μ=12n1vVd(u,v)=12n1(2(i=1n1i)+n)=2n(n1)2+n2n1=n22n1=n2+o(1).

Similarly, for the hypercube graph Qn, we have D=n and

μ =12n1vVd(u,v)=12n1k=1nvV,d(u,v)=kk
=12n1k=1nk(nk)=n2n12n1=n2+o(1).

In fact, we can prove a general result that encompasses both of the previous examples: a class of graphs that is even “more symmetric” than vertex-transitive have D2μ. Let us introduce the required definitions.

Definition 13 (Distance Transitivity).

A graph G=(V,E) is distance transitive, if for every (not necessarily distinct) four vertices u,v,x,yV with d(u,v)=d(x,y), there exists an automorphism φ of G such that φ(u)=x and φ(v)=y.

Note that vertex-transitivity implies distance-transitivity (by taking u=x and v=y), but the converse is not true.

Definition 14 (Antipodal graphs).

Given a graph G=(V,E) of diameter D, we say a vertex vV is antipodal to a vertex uV if d(u,v)=D. A graph is said to be antipodal if for every vertex uV there exists exactly one vertex vV that is antipodal to u.

We can now state the following result, whose proof is presented in Appendix B to avoid disrupting the flow of the main text.

Theorem 15.

Let G be an antipodal distance-transitive graph of diameter D and mean distance μ. Then, D=2μ1.

4 The Demigod Number for the Rubik’s Cube

Theorem 12 allows us to translate upper bounds for the average distance into upper bounds for the diameter. This is particularly useful, as the average distance is easier to certify with high confidence than the diameter. In order to provide an upper bound of the average distance we will follow the following strategy:

  • We will sample a large number (500 000) of uniformly random states of the Rubik’s Cube.

  • For each state, we use an efficient solver333We use https://github.com/efrantar/rob-twophase since it was the fastest solver we could find online. to obtain an upper bound on the distance, which is certified by the move sequence that the solver outputs.

  • We use a simple concentration bound to argue that the empirical average of the distances is a good estimate of the true average distance.

Indeed, let us prove Theorem 1 right away, after which we will explain the precise methodology used to efficiently obtain a diameter upper bound with high confidence. Besides Theorem 17, we need the following standard concentration inequality.

Lemma 16 (Hoeffding’s inequality).

Let X1,X2,,Xs be independent random variables, all with expectation μ, and such that Xi[0,C]. Then, if μ^=1si=1sXi, we have for every t>0 that

𝐏𝐫[μ^μ+t]exp(2st2C2).
Theorem 1. [Restated, see original statement.]

Given a state s of the Rubik’s Cube, let d(s) be the distance from s to the solved state. Let S be a set of states of the Rubik’s Cube sampled uniformly at random, and let μ^S=1|S|sSd(s) be the random variable corresponding to the average distance between states in S and the solved state. Then, if D denotes the diameter of the Rubik’s Cube, we have

𝐏𝐫S[D2μ^S+0.36]<exp(|S|648 534).
Proof.

Let G be the Rubik’s Cube graph, which is vertex-transitive by Lemma 9. Let s denote the vertex of G corresponding to the solved state. Then, let X1,,X|S| be i.i.d random variables corresponding to the distance between a uniformly random vertex of G and s. Using Lemma 10 we have 𝔼[Xi]=μ, and by Lemma 2, we have that Xi[0,205]. Also, μ^S=(i=1|S|Xi)/|S|. Therefore, applying Lemma 16 with t=0.18, we get

𝐏𝐫[μμ^S+0.18]exp(2|S|0.1822052)<exp(|S|648 534).

As D<2μ by Theorem 12, we conclude

𝐏𝐫[D2μ^S+0.36]𝐏𝐫[2μ2μ^S+0.36]<exp(|S|648 534).

4.1 Randomly sampling cubes

To obtain our estimates on μclose and to determine we need an effective procedure for sampling states of the Rubik’s Cube uniformly at random. While in a general Cayley graph this is not necessarily efficient, with the study of mixing times of random walks being a hairy problem, the particular structure of the Rubik’s Cube allows us to sample uniformly at random in a very efficient way.

Indeed, imagine that we take out all 20 (8 corner pieces, 12 edge pieces) non-center “cubies444A cubie is a rather standard term to denote one of the pieces of physical Rubik’s cube, which involves two stickers if it is an edge, and three if it is a corner. of the Rubik’s Cube and rearrange them into a new cube. The following theorem states under what conditions such a rearrangement is a valid state of the cube (i.e., a state that can be reached from the solved state through legal moves).

Theorem 17 (Fundamental Theorem of Cubology, [14, Theorem 20.2.1], [15]).

A rearrangement of the cubies is valid if and only if

  • The permutation of the corners has the same parity as the permutation of the edges. (See [14, Theorem 20.2.1] for a formal definition)

  • The number of corners that are oriented clockwise equals the number of corners that are oriented counterclockwise modulo three. (See Figure 4c for an example of corner orientation.)

  • The number of flipped edges is even. (See Figure 4a for an example of flipping an edge.)

Interestingly, Theorem 17 implies an efficient algorithm for sampling. Consider the following three non-valid operations in the cube:

  1. 1.

    Flip the edge between F and U (see Figure 4a).

  2. 2.

    Swap the corners at the intersection of F, U, L and F, U, R (see Figure 4b).

  3. 3.

    Turn clockwise the corner at the intersection of D, U, R (see Figure 4c).

(a) Flipping an edge.
(b) Swapping two corners.
(c) Turning a corner.
Figure 4: Three invalid operations.

Performing these three operations leads to 12 cube configurations (there are 2 choices for flipping the edge, 2 choices for swapping the corners, and 3 choices for turning the corner). Theorem 17 implies that out of these 12 configurations, exactly one of them is valid, no matter the state the rest of the cube is in. Thus, the algorithm that reassembles the cube at random and rejects invalid states by Theorem 17, takes (in expectation), 12 reassembles to uniformly sample a state of the cube. Furthermore, the algorithm that reassembles the cube at random and fixes an invalid state by performing the three operations of Figure 4 takes only 1 re-assembly of the cube to sample uniformly.

In summary, while disassembling a Rubik’s Cube and reassembling into the solved state is considered a rather lame way of solving the cube, reassembling it randomly (and fixing the state if it is invalid) is an efficient way to sample uniformly at random from the cube.

Finally, note that, by vertex-transitivity, sampling a random pair in the cube has the same distance distribution as sampling one state of the cube and giving the distance to a fixed state. We will use the solved state as the fixed state in our computations and experiments.

4.2 Experimental results

Using the aforementioned methodology, we sampled 500 000 uniformly random states of the Rubik’s Cube. Out of these, no state required more than 20 moves to be solved, and the empirical mean distance obtained was 18.3189. The process took under 5 hours on a personal computer (MacBook Pro M3, 36 GB of RAM, 16 cores). A histogram is displayed in Figure 5. Our experiments can be found in https://github.com/bsubercaseaux/RubikDemiGodNumber/.

Figure 5: Histogram showing 500 000 samples. This plot aggregates how many moves the samples needed to be solved. No more than 20 moves were needed, and the empirical mean was 18.3189.

4.3 Obtaining the Demigod’s number

While Theorem 1 already provides us with a way of obtaining an upper bound for the diameter, its sample complexity is not very practical. To obtain a probability of error of, say, 0.01%, we could set

exp(|S|/648 534)0.0001|S|648 534log(10000)6106,

from where running a solver on each sample for 0.2 seconds, on 8 parallel threads, would take a couple of days. Getting to a probability of error of 1010 would require about a year. Therefore, we now apply a simple method to reduce the sample complexity. We begin by showing that it is highly unlikely that many states of the cube are “far apart”. To this end, we say that a pair of states of the cube is “far apart” if their distance is 21 or more, otherwise, we say that the states are “close”. We then consider the following statement:

ϕ:=“at least 0.03% of the pairs of states of the cube are far apart.” (2)

If ϕ is true, then by sampling enough pairs of states at random we would expect to observe a pair of states that are far apart. We formalize this idea in the following lemma whose proof is straightforward.

Lemma 18.

If the statement ϕ (from (2)) is true, then the probability of sampling s pairs of cube states uniformly at random and observing 0 pairs of states that are far apart is at most (10.0003)s.

We now consider the mean distance between close vertices, μclose; that is,

μclose:=u,v(.V2.)u,v closed(u,v).

Moreover, we consider the empirical mean between close vertices, which we denote by μclose^; that is, we sample pairs at random, compute the distance, discard the results whenever the pairs are far apart, and average the results. Then, we can use Lemma 16 with C=20 to state that μclose and μclose^ are close to each other with high probability, obtaining the following lemma.

Lemma 19.

Let μclose^(s) be the empirical mean distance over s samples. Then,

𝐏𝐫[μclose^(s)μclose+0.1]exp(0.00005s).

By Lemma 18, if we assume statement ϕ, then the probability of observing no pair of states that are far apart when sampling 500 000 pairs of states is at most

(10.0003)500 000<7.021066.

However, that is exactly what we observed, and it can be easily certified by exhibiting the sequences of moves that transform one state into the other (included in our supplementary material). Therefore, we have very significant empirical evidence (i.e., 11065 confidence interval) for the statement ϕ being false. Equivalently, we have empirical evidence for:

“at most 0.03% of the pairs of states of the cube are far apart.” (3)

Furthermore, the empirical mean observed with 500 000 samples was 18.3189.

Since exp(0.00005500 000)1.381011, by Lemma 19, we have significant empirical evidence that

μclose18.3189+0.1=18.4189. (4)

Combining facts (3) and (4) with Lemma 2, we have significant empirical evidence that

μμclose+0.03%20518.4189+0.0615=18.4804. (5)

As 218.4804=36.9608, using a union bound, and Theorem 12, the probability of seeing our empirical observations if the Rubik’s Cube diameter were to be 37 or larger, is no more than

1.381011+7.021066<1010,

and thus we have shown how to obtain a high degree of confidence with relatively few samples. Following this same approach for 90 minutes of computation results in a probability of error of roughly 104, and thus during a lecture one could convince an audience of a 1-in-10 000 chance that the diameter of the Rubik’s Cube is larger than 36.

5 Discussion

We have presented a novel approach to bounding the number of moves required to solve any state of the 3×3×3 Rubik’s Cube, which relies on three simple aspects of the cube: (i) its vertex-transitivity, (ii) our ability to efficiently sample uniformly random states from it, and (iii) good empirical algorithms. Because these properties extend to a variety of combinatorial puzzles (both to puzzles in the Rubik’s family, such as the Piraminx or the Megaminx, as well as unrelated puzzles like the 15-puzzle on a torus), we expect that this methodology can be used to obtain similar results for other puzzles without spending the computational resources required to fully explore their state graphs. Moreover, while God’s number is known for the 3×3×3 cube, it remains widely open for larger puzzles [20] (with a gap larger than by a factor of 2 between lower bound and upper bound already for the 5×5×5 cube), where our approach could be useful provided a good algorithm without requiring theoretical guarantees on it. In terms of related work, So Hirata has recently released two interesting papers concerning the diameter of Rubik’s puzzles [8, 9], which attack the problem from different angles; either considering the girth of the cube’s graph or using estimations for its branching factor. On a more theoretical line of work, Demaine et al. proved that computing the diameter of an N×N×N Rubik’s cube is NP-hard [6]555More in general, computing the diameter of a Cayley graph is NP-hard given a group presentation [3]., and that the diameter of the N×N×N cube is Θ(N2logN) [5].

A particular characteristic of our approach is that our result has an intermediate epistemic status between a theorem and a heuristic. The situation, more in general, is closely related to the question of how much power randomness gives to computation. In the context of mathematical results, such a question may be phrased as follows:

Are there properties of finite mathematical objects that can only be certified efficiently to a high degree of confidence by probabilistic algorithms, but that we never can be certain of through a short proof?

For instance, consider primality testing; whether a given number is prime or not is a fully deterministic fact, in the same way as the average distance of the Rubik’s Cube graph is. However, in order to practically obtain knowledge of such deterministic facts, we leverage the computational benefit of randomness, which allows us (at least in current practice), to determine facts that otherwise would be out of reach. The cost, however, is the possibility of error in the associated randomized algorithms, which forbids us from claiming to have definite proofs of the facts of interest. As usual, we can get such probability of error to be as small as we deem necessary for convincing ourselves, at a modest computational price, while keeping the curse of never reaching 100% confidence. An interesting (albeit brief) discussion of this general issue can be found in Gil Kalai’s blog [12].

Going back to our case, we have shown that, if one assumes momentarily that the diameter of the Rubik’s Cube graph is larger than 36, then observing an empirical mean distance of around 18.3 over 500 000 samples, none of which required more than 20 moves, has probability under 1010. We encourage the readers to reproduce this computation by themselves, which should take less than a day in any modern computer. We believe this makes an extremely compelling case for the diameter of the Rubik’s Cube graph being at most 36 while using a fraction of the computation required by previous approaches. Moreover, we hope that this same line of attack can be useful for analyzing other puzzles or graphs.

References

  • [1] Christoph Bandelow. Inside Rubik’s Cube and Beyond. Birkhäuser Boston, 1982. doi:10.1007/978-1-4684-7779-5.
  • [2] Jonathan Borwein and David Bailey. Mathematics by Experiment: Plausible Reasoning in the 21st Century. A K Peters/CRC Press, New York, 2 edition, 2011. doi:10.1201/b10704.
  • [3] Jin-Yi Cai, George Havas, Bernard Mans, Ajay Nerurkar, Jean-Pierre Seifert, and Igor Shparlinski. On Routing in Circulant Graphs. In Takano Asano, Hideki Imai, D. T. Lee, Shin-ichi Nakano, and Takeshi Tokuyama, editors, Computing and Combinatorics, pages 360–369, Berlin, Heidelberg, 1999. Springer. doi:10.1007/3-540-48686-0_36.
  • [4] JJ Chen. Group theory and the Rubik’s cube, 2004.
  • [5] Erik D. Demaine, Martin L. Demaine, Sarah Eisenstat, Anna Lubiw, and Andrew Winslow. Algorithms for solving rubik’s cubes. In Camil Demetrescu and Magnús M. Halldórsson, editors, Algorithms - ESA 2011 - 19th Annual European Symposium, Saarbrücken, Germany, September 5-9, 2011. Proceedings, volume 6942 of Lecture Notes in Computer Science, pages 689–700. Springer, 2011. doi:10.1007/978-3-642-23719-5_58.
  • [6] Erik D. Demaine, Sarah Eisenstat, and Mikhail Rudoy. Solving the Rubik’s cube optimally is np-complete. In Rolf Niedermeier and Brigitte Vallée, editors, 35th Symposium on Theoretical Aspects of Computer Science, STACS 2018, February 28 to March 3, 2018, Caen, France, volume 96 of LIPIcs, pages 24:1–24:13. Schloss Dagstuhl – Leibniz-Zentrum für Informatik, 2018. doi:10.4230/LIPIcs.STACS.2018.24.
  • [7] Mark Herman and Jonathan Pakianathan. On the distribution of distances in homogeneous compact metric spaces. Topology and its Applications, 193:97–99, 2015. doi:10.1016/j.topol.2015.06.011.
  • [8] So Hirata. Graph-theoretical estimates of the diameters of the Rubik’s cube groups, 2024. doi:10.48550/arXiv.2407.12961.
  • [9] So Hirata. Probabilistic estimates of the diameters of the Rubik’s cube groups, 2024. doi:10.48550/arXiv.2404.07337.
  • [10] Nathan Jacobson. Basic Algebra I. Dover Books on Mathematics. Dover Publications, Mineola, NY, 2 edition, June 2009.
  • [11] JPerm. Learn How to Solve a Rubik’s Cube in 10 Minutes (Beginner Tutorial). https://www.youtube.com/watch?v=7Ron6MN45LY, 2019. [Accessed 03-08-2024].
  • [12] Gil Kalai. The probabilistic proof that 2400593 is a prime: a revolutionary new type of mathematical proof, or not a proof at all? https://gilkalai.wordpress.com/2021/04/22/the-probabilistic-proof-that-2400-593-is-a-prime-a-revolutionary-new-type-of-mathematical-proof-or-not-a-proof-at-all/, 2011. [Accessed 23-04-2025].
  • [13] Herbert Kociemba. Close to God’s algorithm. In Cubism for Fun, pages 10–13, 1992.
  • [14] James T. Mulholland. Math 302: Combinatorial mathematics. http://www.sfu.ca/˜jtmulhol/math302/notes/302notes.pdf. [Accessed 08-08-2024].
  • [15] James T. Mulholland. Permutation puzzles - Rubik’s cube. https://www.sfu.ca/˜jtmulhol/math302/puzzles-rc-cubology.html. [Accessed 08-08-2024].
  • [16] G. Polya. Mathematics and Plausible Reasoning, Volume 1: Induction and Analogy in Mathematics. Princeton University Press, 1954. doi:10.2307/j.ctv14164db.
  • [17] Tomas Rokicki, John Dethridge, Herbert Kociemba, and Morley Davidson. God’s Number is 20. https://www.cube20.org/. [Accessed 08-08-2024].
  • [18] Tomas Rokicki, John Dethridge, Herbert Kociemba, and Morley Davidson. God’s Number is 26 in the Quarter Turn Metric. https://cube20.org/qtm/. [Accessed 08-08-2024].
  • [19] Tomas Rokicki, Herbert Kociemba, Morley Davidson, and John Dethridge. The Diameter of the Rubik’s Cube Group Is Twenty. SIAM Review, 56(4):645–670, 2014. doi:10.1137/140973499.
  • [20] Speedsolving.com Wiki. God’s Algorithm - Optimal solutions of the Rubik’s Cube. https://www.speedsolving.com/wiki/index.php/God%27s_Algorithm#Table_of_God.27s_Numbers, 2024. [Accessed 06-08-2024].
  • [21] Douglas B. West. Problems in Graph Theory and Combinatorics. http://dwest.web.illinois.edu/openp/. [Accessed 02-08-2024].
  • [22] Baoyindureng Wu, Guojie Liu, Xinhui An, Guiying Yan, and Xiaoping Liu. A conjecture on average distance and diameter of a graph. Discrete Mathematics, Algorithms and Applications, 03(03):337–342, 2011. doi:10.1142/S1793830911001255.

Appendix A The Beginner’s Method and the “Human’s Number”

In order to make this article self-contained, we provide a brief overview of the “beginner’s method” to solve the Rubik’s Cube666We encourage, nonetheless, the interested reader to look into the many YouTube videos (e.g., [11]) that guide the process. , from which we have the following:

Lemma 2 (Human’s Number). [Restated, see original statement.]

Any position of the Rubik’s Cube can be solved in at most 205 moves.

In a nutshell, the beginner’s method consists of solving the Rubik’s Cube by “layers”, as opposed to by faces. Before we begin with its exposition, however, it is worth establishing some notation for the different Rubik’s Cube moves. We will use “Singmaster” notation, credited to British mathematician David Singmaster. To specify a turn on a face, we use the first letter of the face’s name: R for the right face, L for the left face, U for the upper face, D for the down face, F for the front face, and B for the back face. If the face is to be rotated by 90 clockwise, we add no suffix, e.g., R means a clockwise rotation by 90 of the right face. For a counterclockwise rotation by 90, we add a prime symbol, e.g., D’ means a counterclockwise rotation by 90 of the down face. For a 180 rotation, we add a 2 after the letter, e.g., F2 means a 180 rotation of the front face. A proper formalization of what a “move” actually is can be found in Section 2, where we view the Rubik’s Cube as a group. As an example to check our understanding of the notation, the non-commutativity of the Rubik’s Cube group is evidenced in Figure 6.

(a) Result of RD’ from the solved state.
(b) Result of D’R from the solved state.
Figure 6: Illustration of the non-commutativity of the Rubik’s Cube.

Step 1: The white cross

Figure 7: The white cross is solved.

The first step consists of creating a “cross” on one face of the cube, which we will assume to be white without loss of generality. To achieve this, one must move every white “edge” (i.e., a piece with two colors) to the correct position. That is, e.g., the white-orange edge must be placed so that its white sticker is adjacent to the white center and its green sticker is adjacent to the orange center. We illustrate the result of this step in Figure 7, and a conservative bound is that this can always be achieved in 20 moves, as each of the 4 white edges to place can always be placed in at most 5 moves or fewer. This step can be done intuitively, that is, without memorizing any particular algorithm777In the Rubik’s Cube literature, a move sequence with a concrete purpose (e.g., permuting 3 corner pieces) is traditionally called an “algorithm”..

Step 2: White corners

Figure 8: The white corners are solved, and thus the first layer is completed.

The second step consists of placing the white corners in their correct position, one by one. To place a white corner, one can first bring it to the opposite layer (i.e., the bottom layer, whose center is yellow), and then proceed according to a handful of cases, one of which is illustrated in Figure 9. The result of this step is illustrated in Figure 8. Conservatively, this step can always be achieved in 15 moves per corner, and 60 in total. This accounts for the cases when a white corner is in the correct location but oriented incorrectly, in which case a non-white corner can be placed in that spot, thus allowing the white corner to be placed in the correct orientation afterward.

Figure 9: Illustration of one of the cases for placing a corner in the first layer (Step 2 of the beginner’s method), through the move sequence D’R’DR.

Step 3: Edges of the second layer

Figure 10: The first two layers are solved.

The third step consists of placing the edges of the second layer in their final position, as illustrated in Figure 10. For instance, the orange-green edge must be placed so that its orange sticker is adjacent to the orange center and its green sticker is adjacent to the green center. The main algorithm to solve this step is illustrated in Figure 11. A conservative bound, again due to cases in which a misoriented edge must be first replaced before placing it in the correct orientation, is 20 moves per edge.

Figure 11: Illustration of the algorithm to solve the edges of the second layer (Step 3 of the beginner’s method).

Step 4: The yellow cross

We now turn our attention to the yellow face. The goal of this step is to solve the orientation of the yellow cross, that is, to make all yellow edges have their yellow sticker adjacent to the yellow center, as depicted in Figure 12(d). We may face three different scenarios in this step (if it is not already solved), as illustrated in Figure 12. These can all be solved by the same algorithm, potentially repeated according to which of the three non-solved cases we encounter. The algorithm is simply: FRUR’U’F’. Applying it from case 12(a) leads to case 12(b), and applying it again leads to case 12(c), from where a last application solves the yellow cross. That way, we need at most 3 applications, leading to a conservative bound of 18 moves for this step.

(a) No edges oriented correctly.
(b) Non-opposite edges oriented correctly.
(c) Opposite edges oriented correctly.
(d) A possible state after solving the yellow cross.
Figure 12: Illustration of Step 4 of the beginner’s method.

Step 5: Permuting yellow edges

Now, we permute the yellow edges so that each of them gets to its desired position. This step can be solved by repeated application of a single algorithm, that induces a 3-cycle of the yellow edges, as illustrated in Figures 14(b) and 13. As this algorithm is applied at most 3 times, we have a conservative bound of 21 moves for this step.

Figure 13: Illustration of a case for Step 5 of the beginner’s method.

Step 6: Permuting yellow corners

(a) 3-cycle permutation of corners induced by RU’L’UR’U’LU.
(b) 3-cycle permutation of edges induced by RU2R’U’RU’R’.
Figure 14: Illustration of the 3-cycle algorithms for permuting yellow corners and edges, corresponding to Steps 5 and 6 of the beginner’s method.

This step is analogous to the previous one but over the corners; we permute the yellow corners so that each of them gets to its desired position. This step can also be solved by repeated application of a single algorithm, that induces a 3-cycle of the yellow corners, as illustrated in Figures 14(a) and 15. This algorithm is applied at most 3 times, leading to a conservative bound of 24 moves for this step.

Figure 15: Illustration of a case for Step 6 of the beginner’s method.

Step 7: Orienting yellow corners

The last step consists of orienting the yellow corners, which again can be achieved by repeated applications of a single algorithm that changes the orientation of two adjacent corners (illustrated in Figure 16):

RU2R’U’RU’R’L’U2LUL’UL.

This algorithm needs to be applied at most 3 times, leading to a conservative bound of 42 moves for this step.

Figure 16: Illustration of a case for the final step of the beginner’s method, using the move sequence: RU2R’U’RU’R’L’U2LUL’UL.

The following table summarizes the “proof” of Lemma 2:

Step Moves
White cross 20
White corners 60
Edges of the second layer 80
Yellow cross 18
Permuting yellow edges 21
Permuting yellow corners 24
Orienting yellow corners 42
Total 205

Appendix B Proof of Theorem 15

Before the proof, we will need a couple of auxiliary observations. Given that distance-transitive graphs are vertex-transitive, we already have D<2μ by Theorem 12. Therefore, it will suffice to prove that 2μ1D, and then use that D must be an integer.

For a graph G=(V,E), and vertex uV, let Γu(i):={vVd(u,v)=i} be the set of vertices at distance exactly i from u.

Lemma 20.

Let G=(V,E) be an antipodal distance-transitive graph, and uV any vertex. Then, for every i{0,,D}, we have

|Γu(i)|=|Γu(Di)|.
Proof.

Let v be the only vertex antipodal to u. As distance transitivity implies vertex transitivity, we have by Lemma 7, that |Γu(i)|=|Γv(i)| for all i{0,,D}. Therefore, our goal is to show that |Γv(i)|=|Γu(Di)| for all i{0,,D}. Indeed, fix any i{0,,D}, and let wV be an arbitrary vertex such that d(v,w)=i. Then, let z be an arbitrary vertex that is in some shortest path between u and v, and such that d(z,v)=i. Note that as z is in a shortest path between u and v, we have d(z,u)=Di. Now, due to distance transitivity, there exists an automorphism φ of G such that φ(v)=v, and φ(w)=z. By Lemma 7, we have that

d(u,w)=d(φ(u),φ(w))=d(φ(u),z),

and we claim that φ(u)=u. Indeed, since D=d(u,v)=d(φ(u),φ(v))=d(φ(u),v), we know that φ(u) is antipodal to v, and as u is antipodal to v, we have φ(u)=u since G is antipodal. Therefore, we have d(u,w)=d(u,z)=Di, and thus wΓu(Di). As w was arbitrary, we have Γv(i)Γu(Di). Because the previous argument is symmetric in u and v, and can be used with Di instead of i, we have Γu(D1)Γv(i), and thus Γv(i)=Γu(Di). This concludes the proof.

We are now ready to prove Theorem 15.

Proof of Theorem 15.

Fix any vertex uV(G). Using Lemmas 10 and 20, we have

(|V(G)|1)μ =i=0Di|Γu(i)|
=i=0D/2i|Γu(i)|+i=0D/2(Di)|Γu(Di)|
i=0D/2i|Γu(i)|+(Di)|Γu(i)|
=Di=0D/2|Γu(i)|.

But we also have

|V(G)|=i=0D|Γu(i)|2i=0D/2|Γu(i)|,

and therefore

μD|V(G)|2(|V(G)|1)=D2+D2(|V(G)|1)D2+12,

from where we can easily conclude. Indeed, μD2+12 implies 2μ1D. Since D is an integer, this implies 2μ1D, and by Theorem 12, we have

D<2μ2μ2μ1+1.

Hence, D is an integer such that 2μ1D<2μ1+1, and thus we conclude D=2μ1.