The Butterfly puzzle is a beautiful wooden puzzle by Clever Toys that has two loops of balls side by side. In the middle is a sliding part that contains a section of track that is shared by the to loops. If the slide is to the left, only the balls in the left loop can be moved, as the right loop is incomplete. Similarly only the right loop can move if the slide is on the right. The seem to be 18 balls in a complete loop, of which four lie on the section on the slide. However, a loop actually has a single ball, followed by a pair of balls stuck together, then another single ball, another connected pair, and so on all the way around the loop. The five balls (pair, single, pair) in top section of each loop are coloured yellow, and the five balls at the bottom (again a pair, single, pair) are coloured brown. The aim of the puzzle is of course to recover this colour pattern after it has been mixed.

This puzzle was invented and patented by Martin Lapeš, CZ 13357, published 9 June 2003.

If your browser supports it, you can click on the link below to play with a Javascript version of the Butterfly puzzle.

I have done a computer analysis of the Butterfly puzzle in order to find God's Algorithm for it. The results are in the table below. Analogous to the Rubik's cube, there are two ways to count the moves. The Face Turn Metric means that a shifting the balls of either loop by any amount is a single move. The "Quarter" Turn Metric means that only shifting a loop by 3 balls is counted as a single move. The tables show that it can be solved in no more than 13 face turns (10.334 on average), or at most 20 three-ball shifts (15.780 on average).

Face turn metric | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|

0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | Total | ||

Q u a r t e r t u r n m e t r i c | 0 | 1 | 1 | |||||||||||||

1 | 4 | 4 | ||||||||||||||

2 | 4 | 8 | 12 | |||||||||||||

3 | 2 | 16 | 16 | 34 | ||||||||||||

4 | 16 | 48 | 28 | 92 | ||||||||||||

5 | 8 | 72 | 120 | 52 | 252 | |||||||||||

6 | 1 | 64 | 248 | 288 | 98 | 699 | ||||||||||

7 | 32 | 320 | 758 | 656 | 168 | 1,934 | ||||||||||

8 | 8 | 264 | 1,246 | 2,094 | 1,440 | 272 | 5,324 | |||||||||

9 | 140 | 1,398 | 4,266 | 5,448 | 2,992 | 368 | 14,612 | |||||||||

10 | 44 | 1,072 | 6,048 | 13,200 | 13,658 | 5,190 | 410 | 39,622 | ||||||||

11 | 8 | 580 | 6,128 | 22,730 | 39,392 | 29,598 | 6,636 | 232 | 105,304 | |||||||

12 | 192 | 4,330 | 28,056 | 80,496 | 105,524 | 47,738 | 4,604 | 28 | 270,968 | |||||||

13 | 32 | 2,024 | 25,260 | 120,366 | 260,976 | 212,374 | 41,018 | 758 | 662,808 | |||||||

14 | 4 | 580 | 15,678 | 128,140 | 457,610 | 645,133 | 223,023 | 8,796 | 20 | 1,478,984 | ||||||

15 | 96 | 6,082 | 89,532 | 545,120 | 1,322,250 | 807,750 | 57,142 | 68 | 2,828,040 | |||||||

16 | 1,100 | 35,292 | 378,979 | 1,626,240 | 1,824,024 | 234,810 | 548 | 4,100,993 | ||||||||

17 | 80 | 5,834 | 121,010 | 934,393 | 2,026,794 | 519,464 | 2,138 | 3,609,713 | ||||||||

18 | 224 | 11,560 | 167,624 | 732,414 | 404,715 | 4,771 | 1,321,308 | |||||||||

19 | 140 | 4,830 | 45,531 | 58,698 | 2,203 | 111,402 | ||||||||||

20 | 4 | 204 | 618 | 68 | 894 | |||||||||||

Total | 1 | 10 | 49 | 240 | 1,172 | 5,622 | 26,320 | 119,242 | 516,198 | 1,916,075 | 4,967,632 | 5,705,594 | 1,285,029 | 9,816 | 14,553,000 |

Three of the 68 most difficult positions are shown below. Their mirror images form three more.

This puzzle is very closely related to the Turnstile and Puzzler. In fact there is a direct correspondence between their pieces: The single balls are equivalent to the triangular 'corners', and the ball pairs are equivalent to the rectangular 'edges'. If you understand how to solve Turnstile, then this correspondence makes it quite easy to solve the Butterfly, too.

Let a clockwise shift of the left loop by three balls be denoted by L. An anti-clockwise shift of the left loop by three balls is denoted by L'. Turns of the right loop are denoted in the same way, but using the letter R instead, so R for a clockwise and R' for an anti-clockwise shift of the right loop by three balls.

A solution for the Butterfly puzzle is fairly easily constructed by the use of the simple move sequence LR'L'R. This sequence swaps two pairs of single balls, and also does a 3-cycle of ball pairs. If you perform it twice then the single balls remain unmoved but it is still a 3-cycle of ball pairs. If you perform it three times then the ball pairs remain unmoved but still does a double swap of single balls, though if you solve the single balls before solving the ball pairs you don't need to do this. Below I will explain a solution to the Butterfly puzzle in more detail.

Hold the puzzle with the yellow end at the top, and the brown end at the bottom.

- Bring one of the single yellow balls to the left loop (not on the slide), and one of the brown balls to the right loop (again not on the slide). This is quit easy.
- Turn the left loop so that the yellow ball lies on the left hand side of the loop, just above the middle.
- Turn the right loop so the brown ball lies at the bottom end of the slide.
- Turn the left loop so that the yellow and brown balls are at their correct spots at the top and bottom of the loop.
- Turn the right loop so that the other yellow or other brown ball lies at the bottom end of the slide, and the top end of the slide has a blank ball.
- Do LLL, i.e. shift the left loop by 9 balls (exchanging the top/bottom balls, bringing the coloured ball the left, above centre).
- Turn the right loop so that the other remaining coloured ball lies at the right, just above the middle.
- Do LLL again, i.e. shift the left loop by 9 balls (restoring the top/bottom balls again).
- Turn the right loop so that its two coloured balls are in their correct spots at the top and bottom of the loop.

**Phase 2:** Solve the ball pairs.

- If there is a coloured ball pair on the slide, then go to step d.
- If there is a coloured ball pair on the left of the left loop, then do LLL RRR LLL RRR. This brings the coloured pair to the slide. Then go to step d.
- If there is a coloured ball pair on the right of the right loop, then do RRR LLL RRR LLL. This brings the coloured pair to the slide. Then go to step d.
- To place the centre ball pair in position, then do one of the following sequences depending on where it should go:

Top left of left loop: RL LR'L'R LR'L'R L'R'

Top right of left loop: R'LRL' R'LRL'

Top left of right loop: LR'L'R LR'L'R

Top right of right loop: L'R' R'LRL' R'LRL' RL

Bottom left of left loop: R'L' L'RLR' L'RLR' LR

Bottom right of left loop: RL'R'L RL'R'L

Bottom left of right loop: L'RLR' L'RLR'

Bottom right of right loop: LR RL'R'L RL'R'L R'L'

Note that if you could not get a coloured ball pair to the centre in steps a-c, then by the same method you can use the blank centre pair to displace any incorrectly placed ball pair. - Repeat steps a-d until the puzzle is solved.

1. |
R'LL RRL R'LL R'LL RL' RL'L' R'L' | |

2. |
L'RR LLLR' LLRRR LRRL |