1. What is the shortest possible length of an algorithm that generates on each side of the cube a pattern that has:

    • 6 colors
    • at most 2 facelets of the same color
    • no adjacent facelets of the same color
  2. What is the algorithm (or algorithms)?

* I don't know if that's how such a pattern is called but I had to keep the title as concise and as descriptive as possible.

  • 1
    $\begingroup$ code golf questions usually ask for the shortest program (in bytes) but there is actually a lot of flexibility there. You might consider asking for the "shortest algorithm" as long as you can define what that means. It could be fewest swaps or fewest comparisons or fewest Turing machine-like instructions. Those folks are really nice and also pretty flexible, but you mght ask a meta question first to get assistance defining exactly what "shortest" means before you post the actual question. $\endgroup$
    – uhoh
    Commented Nov 21, 2023 at 20:06
  • 1
    $\begingroup$ @uhoh Thank you. $\endgroup$
    – q-l-p
    Commented Nov 21, 2023 at 20:25
  • 1
    $\begingroup$ @uhoh After 5 years, I got my answer! Check out Seven Face Turns And what an unbelievable answer! $\endgroup$
    – q-l-p
    Commented Nov 22, 2023 at 2:07
  • $\begingroup$ Excellent! I think that code golf is one of the nicest and most interesting SE sites that I've participated in. By the way, unlike most SE sites, it's quite common to not accept answers ever, and certainly not so quickly. See this answer to my old meta question there: Usually, the practice is that code golf challenges don't accept answers (same goes with code-bowling and code-challenge. $\endgroup$
    – uhoh
    Commented Nov 22, 2023 at 4:05

1 Answer 1


While I was was sieving through hundreds of patterns, using Herbert Kociemba's Cube Explorer, I stumbled upon a pattern, shown in the animation* below, that can be generated by a 15-move algorithm. But I don't know if this is the shortest algorithm which generates a harlequin pattern.

Harlequin pattern on a rotating Rubik's Cube
D' F L2 D F U2 B U' R' L F B L2 D L'

UPDATE – I found another one!
F R B D B F2 R2 U2 L' F' L D2 B R2 U

Today I decided to systematically search for the shortest harlequin algorithm using Kociemba's program. I started by manually counting the number of harlequin search patterns to be used in the Pattern Editor. There are 7 ways to arrange the first 2 facelets of the 1st color (excluding rotation symmetry):
enter image description here

For patterns 1 and 5 there are only 13 ways to arrange the next 2 facelets of the 2nd color:
enter image description here

For patterns 2, 6 and 7 there are 15 ways to arrange the 2nd color facelet pair. For patterns 3 and 4 there are 14 ways.

So, there are 99 ways in which the first 4 facelets can be arranged. For pattern 1 I counted 80 ways in which the 3rd color facelet pair can be placed. Because the colors of the search pattern only tell the program the structure of the pattern and not the actual colors to be searched, it doesn't matter how we color the last 3 facelets as long as each has a unique color. So there are 80 search patterns that begin with pattern 1. Pattern 2 is the starting point for 110 search patterns. Pattern 3 generates 94 search patterns. But I ran into a roadblock. Some search patterns produce 7 results, some 164 and some... OVER 9000!!

I had to stop the program after letting it run for more than 24 hours. It was still searching for patterns.

Obviously, it is unfeasible to manually search for the shortest harlequin generator. I hope someone will find a better way to answer this question. I understand that the number of harlequin patterns may be so large that it renders such patterns as... not so special to worth the effort of investigating. I don't know enough math to go any further.

I am still interested in a mathematical solution to this puzzle.

* GIF created using Rubik's Cube Explorer and VirtualDub.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .