# Butterfly 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.

## The number of positions:

The alternating arrangement of pairs and single balls will always remain alternating when it is mixed. There are 10 single balls and 11 pairs, so there are at most 11!·10! positions. This limit is not reached because there are many sets of identical pieces. There are 2 brown, 2 yellow and 6 blank single balls, and 4 brown, 4 yellow, 3 blank ball pairs. This leaves 10!·11! / (2!2·6!·4!2·3!) = 14,553,000 positions.

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 1 4 4 8 2 16 16 16 48 28 8 72 120 52 1 64 248 288 98 32 320 758 656 168 8 264 1,246 2,094 1,440 272 140 1,398 4,266 5,448 2,992 368 44 1,072 6,048 13,200 13,658 5,190 410 8 580 6,128 22,730 39,392 29,598 6,636 232 192 4,330 28,056 80,496 105,524 47,738 4,604 28 32 2,024 25,260 120,366 260,976 212,374 41,018 758 4 580 15,678 128,140 457,610 645,133 223,023 8,796 20 96 6,082 89,532 545,120 1,322,250 807,750 57,142 68 1,100 35,292 378,979 1,626,240 1,824,024 234,810 548 80 5,834 121,010 934,393 2,026,794 519,464 2,138 224 11,560 167,624 732,414 404,715 4,771 140 4,830 45,531 58,698 2,203 4 204 618 68

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

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.

## Notation:

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. ## Solution:

Phase 1: Solve the single balls.
Hold the puzzle with the yellow end at the top, and the brown end at the bottom.
1. 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.
2. Turn the left loop so that the yellow ball lies on the left hand side of the loop, just above the middle.
3. Turn the right loop so the brown ball lies at the bottom end of the slide.
4. Turn the left loop so that the yellow and brown balls are at their correct spots at the top and bottom of the loop.
5. 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.
6. Do LLL, i.e. shift the left loop by 9 balls (exchanging the top/bottom balls, bringing the coloured ball the left, above centre).
7. Turn the right loop so that the other remaining coloured ball lies at the right, just above the middle.
8. Do LLL again, i.e. shift the left loop by 9 balls (restoring the top/bottom balls again).
9. 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.

1. If there is a coloured ball pair on the slide, then go to step d.
2. 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.
3. 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.
4. 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.
5. Repeat steps a-d until the puzzle is solved.

## Pretty Patterns for Butterfly:

 1 R'LL RRL R'LL R'LL RL' RL'L' R'L' 2 L'RR LLLR' LLRRR LRRL 