Running through all permutations of a Rubik's cube [duplicate]

According to Wikipedia a $3 \times3\times3$ Rubik's cube has $43252003274489856000$ permutations.

I never tried solving one myself (too tedious), however I wondered, if one could miraculously "solve" the cube in color blind mode (all faces of the cube have the same color to him or the person is just blind folded). (Yes, it is tedious, but I guess sooner or later he will just hit the right permutation and hopefully someone tells him, that it's good and he may stop.)

I wondered, if there were some kind of "best" approach to run all through those permutations without too many repetitions, for example the algorithm makes sure one gets any permutation at most $n$ times.

I don't know the answer yet and probably won't have it anytime soon. However I would be quite interested in seeing this algorithm and thus I hope the question has been asked before and been solved. Any constructive comment/answer is appreciated.

marked as duplicate by Henning Makholm, Jaideep Khare, Shailesh, mathreadler, Misha LavrovApr 26 '17 at 2:09

• A very rough approach (rough in the sense that it isn't sharp) would be to perform an algorithm which consists of $43252003274489856000$ algorithms, where algorithm $i$ gets you to state $S_i$ and then undoes itself, and all the $S_i$ are distinct. – Irregular User Mar 12 '16 at 17:55
• From the web: link. Found by searching "Hamiltonian rubik graph." – pjs36 Mar 12 '16 at 17:56
• Wow, $n$ can be set to 1 and it's still solveable. I find this quite a feat and the idea of Hamiltonian circuits highly interesting! – Imago Mar 12 '16 at 17:58
• Indeed! I wish I understood it well enough to turn into an answer that's actually good. But the more I look, it doesn't seem like a sequence of repeated moves, rather a bunch of smaller repeated sequences connected in very particular ways -- possibly it's literally a list of U's, R's, and L's that's as long as the number of permutations that exist! – pjs36 Mar 12 '16 at 18:05
• @pjs36 Even if you don't understand the details, you should convert your comment to an answer, together with a short definition of an Hamiltonian path. – J.-E. Pin Mar 19 '16 at 13:17

In this link, it is claimed (and I believe them!) that one can achieve every single permutation of the cube without ever revisiting a single vertex twice. The details are, not surprisingly, pretty devilish.

The basic idea is to imagine creating a graph with one vertex for each permutation of the cube. We'll call the solved state's vertex $1$, and give a name to each vertex depending on the moves that need to be taken to get there from $1$. If you perform the move $URU^3$ starting from $1$, you'll call that vertex $URU^3$ (Note that we have to have some convention about names; they're not unique). It's not especially important for this question, but the graph is called the Cayley graph of the Rubik group -- this is what let me search for an answer, by knowing the magic password.

Your question could now be phrased as, "Are there any circuits (walks that return to where they started, also called cycles) of this Rubik graph that visit each vertex at least once, without too many repeats?" The best kind of circuits are called Hamiltonian circuits, and they visit each vertex exactly before returning to where they started.

What the webpage shows, in full technical jargon, is that the Cayely graph of the Rubik's cube group admits a Hamiltonian circuit.

It's my understanding that it would be completely ridiculously unmanageable to use the circuit they found. It was constructed by "opening up" more and more states of the cube in a very controlled manner.

For example, if you can only use the move $UR$ (not $U$ and $R$ separately, yet), then by repeating the move $UR$ $105$ times, you'll wind up where you started. If you can use any combination of $U$'s and $R$'s, there are a lot more possibilities -- $73{,}483{,}200$, to be precise! But you can string together a bunch of walks that look like $UR$ repeated $105$ times, with some appropriate shifting between walks, to get all $73{,}483{,}200$ moves accessible with only $U$ and $R$.

Apparently the author of the page played that game with increasingly less limited movesets, slowly adding the moves $D,\ L$, and $F$ to their repertoire. So I think the cycle they obtained looks a lot like a bunch of those little $UR$-repeated-$105$-times walks, but with various move combinations thrown in between the walks.

It is definitely not something that could be committed to memory! But probably something a very, very dumb computer could implement to solve the Rubik's cube with absolutely no strategy besides executing an unfathomably large sequence of the basic quarter-turn moves.

• Please note that—assuming the number of possible permutations in that article (43,252,003,274,489,856,000) is correct—the average length of time it would take to solve a given Rubik's cube using that method at 1000 moves per second, would be over 685 million years. – Wildcard Mar 23 '16 at 6:49
• @Wildcard Funnily enough, I was thinking along those lines! I wanted to use the classic "longer than the age of the universe" line, but realized it wouldn't apply :) Still quite a long time, thank you for the calculation! – pjs36 Mar 23 '16 at 13:51
• It does apply if you reduce the turns per second to, say, 15 (i.e. on the order of world-record pace for speed-solving). – aleph_two Dec 25 '18 at 1:52