Finding Short Rubik's Cube Codes

When you see codes for the 3x3x3 Rubik's cube, they're generally used for manipulating the top layer while keeping the lower two layers intact. I'd like to discover all of the last-layer algorithms for various short lengths.

6-Move Codes
There aren't many at first. If we constrain ourselves to a set of 18 moves consisting of clockwise quarter turns of the six faces, (U, D, L, R, F, B), counter-clockwise quarter turns (denoted by appending a typewriter apostrophe ' to the letter of the turned face), and half turns (for which we append a 2), then even though there are 18^6 distinct sequences that are six moves in length, there are, up to rotations and mirror reflections, only two last-layer algorithms among them:

<F  U  R  U' R' F'> and its inverse <F  R  U  R' U' F'>

7-Move Codes:
What about codes that are 7 moves in length?

Let's normalize our presentation of codes in the following way:
  • If a code's first move is on one of the faces (L, R, or B), it should be transformed by rotation into a code that begins with a turn of the F face.
  • Any code which then begins with F' should be transformed into one that begins with F through a left-right reflection.
  • What about codes that begin with F2? A left-right reflection won't change the first move, but it will change any quarter turns that show up later in the move. If a code begins with F2 and contains a quarter turn later on, prefer the left-right variant for which the first quarter turn is made to be clockwise rather than counter-clockwise.
  • Any code that has a turn of the U face at its beginning or end should have those moves simply cut off.
  • Any code that begins with a turn of the D face should have that turn moved to the end.
  • Any two successive turns on the same face should be combined into one turn, and they should also be combined if they're only separated by a turn of the (independent) parallel face.
  • I haven't added this into my normalization procedure yet, so the codes below might not adhere to this rule, but if a code has two successive moves on opposite faces, the two moves can be swapped without changing the result, so perhaps we should establish some ordering (such as U, D, L, R, F, B), and prefer that opposite faces occur in that order, unless the reverse order would result in a reduction according to one of the other rules. For example, "U D" would be preferred to "D U" in the interior of a code, but if "U D" appeared at the end of a code, then by switching to "D U" we could shorten the code by removing the U turn.
Using those normalization rules, there are 5 distinct last-layer codes in 7 moves. These are

<F  U' B' U  F' U' B > | The inverse of which, in normal form, is same code.
<F  U2 F' U' F  U' F'> | <F  U  F' U  F  U2 F'>
<F  R  B' R  B  R2 F'> | <F  R2 B' R' B  R' F'>

Again, this is kind of weird: the number 18^7 is much bigger than 5. It's not as if the number of distinct last-layer configurations (about a thousand, depending on which symmetries you ignore) is the real limiting factor, because I would happily separately count two codes that produced the same configuration. There are just very few sequences that are codes. Oh well. At least it's an easy set to memorize.

8-Move Codes:
How about codes in 8 moves? Surprisingly there are just 19.... probably. The program that I ran in order to find these had a stupid optimization which might have skipped a valid code or two. My guess however is that these are the full set.

<F  R  B  R' F' R  B' R'> | <F  R  F' L  F  R' F' L'>
<F  R  B  U' B' U  R' F'> | <F  R  U' B  U  B' R' F'>
<F  R  B' R' F' R  B  R'> | <F  R' F' L  F  R  F' L'>
<F  R' F  R  F2 L' U2 L > | <F  U2 F' L2 B  L  B' L>
<F  R' F' L  F2 R  F2 L'> | <F  R2 B' R2 F' R  B  R'>
<F  U  F  R' F' R  U' F'> | <F  U  R' F  R  F' U' F'>
<F  U  F' L' B' U' B  L > | <F  R  U' R' F' L' U  L>
<F  U  F' U' F' L  F  L'> | <F  R' F' R  U  R  U' R'>
<F  U2 F' U2 F' L  F  L'> | <F  R' F' R  U2 R  U2 R'>
<F  U  F2 L  F  L2 U  L > | Whose normal-form inverse is the same.


I wish I could say which of these are newly discovered and which are known. Probably all are known, given how small the set is and how much computing power has been thrown at Rubik's cubes, but it's hard to know. People online don't put their codes into normal form, so even if Google can't find one of my codes online, maybe that just means someone has posted a transformed version of it.

9-Move Codes:
How about Last Layer codes in 9 moves? I really don't have any guess as to the size of this set. The search space is huge. If I were to limit myself to codes where each face besides U had face turn conservation (that is, the turns to each face must add up to 0 modulo 4, counting each counter-clockwise turn as -1), then I think I could find all such Last Layer codes in a few days. Maybe I will. It would be pleasing to know that I had exhaustively found all 9-move codes even in that restricted class.

Here are the 9-move normal form codes that I have so far - 76 in total, but I still need to filter out a few equivalent codes that remain unnecessarily due the fact that I haven't yet normalized the order of successive moves on parallel faces.

<F  B' U  R  U' R' F' U' B > | <F  U' B' R' U' R  U  F' B >
<F  B' U' R' U  R  B  U  F'> | <F  U' B' R' U' R  U  B  F'>
<F  D  B2 D' F  D  B2 D' F2> | <F2 D  B2 D' F' D  B2 D' F'>
<F  D2 B2 L  U2 B2 D2 R  F > | <F  L  D2 B2 U2 R  B2 D2 F >
<F  D2 B2 R  B2 D2 F2 L  F > | <F  R  F2 D2 B2 L  B2 D2 F >
<F  L' U2 L  U2 L  F2 L' F > | <F  R' F2 R  U2 R  U2 R' F >
<F  R  B  U' B' U2 R' U' F'> | <F  U  R  U2 B  U  B' R' F'>
<F  R  F  U  F' R' F  U' F2> | <F2 U  F' R  F  U' F' R' F'>
<F  R  U  R' F' U  F  U2 F'> | <F  U2 F' U' F  R  U' R' F'>
<F  R  U  R2 F  R  F' U' F'> | <F  U  F  R' F' R2 U' R' F'>
<F  R  U' R' F' U' L' U2 L > | <F  U2 F' U' L' B' U' B  L >
<F  R  U' R' U  F' L' U  L > | <F  U  F' L' U  B' U' B  L >
<F  R  U' R' U  R  U  R' F'> | <F  R  U' R' U' R  U  R' F'>
<F  R  U' R' U' F' L' U  L > | <F  U  F' L' U' B' U' B  L >
<F  R  U' R' U2 F' L' U  L > | <F  U  F' L' U2 B' U' B  L > 
# Both of the above are equivalent to <U2>. That's a trivial result, but they're still very pretty codes.
<F  R  U' R' U2 R  U  R' F'> | NF-inverse is the same.
<F  R  U2 B  U  B' R' U2 F'> | <F  U2 R  B  U' B' U2 R' F'> 
# The above are equivalent to <U> and <U'> respectively.
<F  R' F  L2 F' R  F  L2 F2> | <F2 R2 F  L  F' R2 F  L' F >
<F  R' F  R  F2 U  L' U  L > | <F  U  F' U  L2 B  L  B' L >
<F  R' F  R2 B' R  B  R2 F2> | <F2 L2 B  L  B' L2 F  L' F >
<F  R' F' U' F  U  R  U' F'> | <F  U  R' U' F' U  F  R  F'>
<F  R' F2 L  F2 R  F2 L' F > | NF-inverse is the same.
<F  R2 B' D  B' D' B2 R2 F'> | <F  R2 B2 D  B  D' B  R2 F'>
<F  U  F  D  F' U' F  D' F2> | <F2 D  F' U  F  D' F' U' F'>
<F  U  F' L' U  L  F  U' F'> | <F  U  F' L' U' L  F  U' F'>
<F  U  F' R' F  U' F' U  R > | <F  U  R' U' R  F' R' U  R >
<F  U  R  U2 R' F' L' U  L > | <F  U  F' L' B' U2 B  U  L >
<F  U2 F  D  B' R2 B  D' F2> | <F2 D  B' R2 B  D' F' U2 F'>
<F  U2 F  D  F' U2 F  D' F2> | <F2 D  F' U2 F  D' F' U2 F'>
<F  U2 F' L  F' L' F2 U2 F'> | <F  U2 F2 L  F  L' F  U2 F'>
<F  U2 F2 U' F2 U' F2 U2 F > | NF-inverse is the same.
<F2 D  B' D' F' D  B  D' F'> | <F  D  B' D' F  D  B  D' F2>
<F2 L2 R2 B2 D  B2 L2 R2 F2> | NF-inverse is the same.
<F2 L2 R2 B2 D  F2 L2 R2 B2> | <F2 R2 L2 B2 D  F2 R2 L2 B2>
<F2 R2 F  L2 F' R2 F  L2 F > | <F  R2 F  L2 F' R2 F  L2 F2>
<F2 R2 L2 B2 D  B2 R2 L2 F2> | NF-inverse is the same.
<F2 U  L  R' F2 L' R  U  F2> | NF-inverse is the same.
<F2 U  R' L  F2 R  L' U  F2> | NF-inverse is the same.
<F2 L  F  L' U' F2 R' F' R > | <F  R' F' R2 U' B' R  B  R2>
# The above are both equivalent to <U'>.
<F  L  F2 L' F  U  F2 U' F2> | <F2 U  F2 U' F' L  F2 L' F'>
<F  U  F' L' U2 L  F  U' F'> | NF-inverse is the same.
<F  R' B2 R  F  R' B2 R  F2> | <F2 L  B2 L' F  L  B2 L' F >

Gosh, that was fun. If you know of someone who's already done or even started this work, please do let me know.

EDIT: While testing for remaining 9-move codes, I did some online searching and found a handy little github repository from Lars Petrus containing a (large) text file with all possible Last Layer algorithms up to fifteen moves here. After normalizing those, I was pleased to find that there were no codes in fewer than 9 moves that I had failed to find, and that for codes of exactly 9 moves, there were only 4 new pairs:

<F  R2 B' R' B  U  R' U' F'> | <F  U  R  U' B' R  B  R2 F'>
<F  R2 D  R  D' R  F2 U  F > | <F  U  F2 L  D' L  D  L2 F >
<F  R2 D  R  D2 F  D  F2 R > | NF-inverse is the same.
<F  U  F' L2 B  L  B' U' L > | <F  U' R' F  R  F2 L' U  L >

None of those violate face turn conservation except in the U face, so I would have found them all eventually, though it would have taken days, and I wouldn't have had this warm satisfaction of knowing that I was done with the project. I'm free!

No comments:

Post a Comment