Panex is a puzzle that was invented by Toshio Akanuma. It resembles the tower of Hanoi, but it is in fact a lot more difficult. It has two towers of 10 pieces. Instead of being made from disks threaded on pegs, the towers are made of pieces that slide along a track. There are 3 vertical sections of track, similar to Hanoi's three pegs, where a tower can be built. These 'pegs' are exactly long enough to hold a completed tower plus one extra piece. A horizontal track connects the top of the three pegs, so that pieces can move from the very top of one 'peg' to the next. At the start, the left peg contains a blue tower, the right peg an orange tower, and the middle peg is empty. The aim is to swap the two towers. The problem is however that disks cannot freely slide all the way down each peg. A disk cannot move to a position lower than where it belongs in a finished tower.

There are two versions of the Panex puzzle. Panex Silver has blue and orange towers as explained above. From the size of blue/orange shape on each piece you can immediately see at which level it belongs in the finished tower. The Panex Gold however has pieces that look identical, one tower grey and the other brown, making it more confusing still.

This is one of the most difficult puzzles on my site. Partly this is because it is hard to do, but also because the solution is extremely long. It is thought that the optimal solution of Panex needs more than 31000 moves. The Japanese collector whom I bought it from did solve it (the Silver version), but it took him 2 months, an hour a day.

If your browser supports JavaScript, then you can play the Panex by clicking the link below. Its built-in solver is not optimal, but is pretty good considering that it can solve any random position.

Paul's PC Repair has a playable Panex, and C source code for an offline version.

David Bagley has a nice playable Java version of Panex here.

Cheesy Games has another simple playable Panex, but without a solver.

Virtually all of the analysis below is based on the paper by Mark Manasse, Danny Sleator, and Victor K. Wei which can be downloaded from Nick Baxter's Panex page.

**Recursion**

Like the towers of Hanoi, this puzzle can be solved recursively. One basic task is swapping a tower of n disks on a side peg with a single disk at level n on the middle peg. The picture below shows this. Let's call this task S_{n}, a swap of level n.

A simpler related task is to move a tower of n disks from a side peg to the middle peg. This similar to the swap S_{n} above, except that one piece is missing. If we can do S_{n}, then we can certainly do this by just leaving out any moves that would involve the missing piece. Let's call this task T_{n}, a transfer of level n.

We can now set up the recursion, defining these level n tasks using smaller tasks of level n-1. The sequence of pictures below shows how this is done.

S_{n} = T_{n-1} + S'_{n-1} + X + S_{n-1}

T_{n} = T_{n-1} + S'_{n-1} + T_{n-1}

Here the inverse of a move or move sequence is denoted by a tick mark. Also new is the move sequence denoted by X, which consists of 4 moves and swaps the top two disks on the middle peg. Note how T_{n} is just like S_{n} but without the unnecessary X swap.

The cases T_{1} and S_{1} are trivial (1 and 3 moves respectively), so this shows that we can definitely perform all these swaps and transfers for any number of disks. To actually solve the puzzle we need to swap the two towers on the outside pegs. We can swap the two bottom disks as follows:

X_{n} = _{L}T_{n} + _{L}T'_{n-1} + _{R}S_{n} + _{R}T'_{n-1} + _{L}T_{n-1} + _{L}T'_{n}

The L and R subscripts indicate on which side the move sequence is performed.

We can repeat this exchange for each level of the puzzle: X_{10} + X_{9} + X_{8} + ... + X_{1} exchanges the pieces at each level, thus exchanging the towers and solving the puzzle. This at least proves the puzzle can be solved.

**Improvement**

The method above is not at all optimal. First of all, the recursive definition of T_{n} has many cancellations in it:

T_{n} = T_{n-1} + S'_{n-1} + T_{n-1}

= T_{n-1} + ( T_{n-2} + S'_{n-2} + X + S_{n-2} )' + ( T_{n-2} + S'_{n-2} + T_{n-2} )

= T_{n-1} + S'_{n-2} + X + S_{n-2} + T'_{n-2} + T_{n-2} + S'_{n-2} + T_{n-2}

= T_{n-1} + S'_{n-2} + X + T_{n-2}

Let's now see how many moves this would take, assuming that there are no cancellations or simplifications anywhere. Let t_{n}, s_{n}, and x_{n} be the number of moves of T_{n}, S_{n} and X_{n} respectively. From the relations above we get the recurrence relations:

s_{n} = 4 + t_{n-1} + 2s_{n-1}

t_{n} = 4 + t_{n-1} + t_{n-2} + s_{n-2}

x_{n} = 3t_{n-1} + 2t_{n} + s_{n}

If we use the boundary conditions s_{1}=3, t_{1}=1, we get the following table:

n | S_{n} | T_{n} | X_{n} | Solution |
---|---|---|---|---|

1 | 3 | 1 | 5 | 5 |

2 | 11 | 5 | 24 | 29 |

3 | 31 | 13 | 72 | 101 |

4 | 79 | 33 | 184 | 285 |

5 | 195 | 81 | 456 | 741 |

6 | 475 | 197 | 1112 | 1853 |

7 | 1151 | 477 | 2696 | 4549 |

8 | 2783 | 1153 | 6520 | 11069 |

9 | 6723 | 2785 | 15752 | 26821 |

10 | 16235 | 6725 | 38040 | 64861 |

For ten disks this gives 64861 moves. Fortunately this is not optimal, so the real number is less. In particular, T_{2} and S_{2} need not be done in 5 and 11 moves respectively, but can easily be done in 3 and 8 moves, because we can make more efficient use of the space in the top row of the puzzle. Similarly, T_{3} can be done in 9 moves. This results in the following table:

n | S_{n} | T_{n} | X_{n} | Solution |
---|---|---|---|---|

1 | 3 | 1 | 5 | 5 |

2 | 8 | 3 | 17 | 22 |

3 | 23 | 9 | 50 | 72 |

4 | 59 | 24 | 134 | 206 |

5 | 146 | 60 | 338 | 544 |

6 | 356 | 147 | 830 | 1374 |

7 | 863 | 357 | 2018 | 3392 |

8 | 2087 | 864 | 4886 | 8278 |

9 | 5042 | 2088 | 11810 | 20088 |

10 | 12176 | 5043 | 28526 | 48614 |

It turns out that there are some small move cancellations here or there in S and T, but even optimally T_{10} needs 4875 moves so this is a rather good method for it. On the other hand, there is a much better way of exchanging the towers than doing the pairs at each level from the bottom up, because we can do much of the work on the top pieces during the exchange of the bottom pair. This is easiest to explain using the following sequence of moves, which we will call Z_{n}:

Z_{n} = _{L}S_{n-1} + _{R}S'_{n-1} + _{R}T'_{n-1} + _{L}T_{n-1}

This transfers the top piece of the left stack across to the bottom of the right stack.

The two towers can now be exchanged as follows:

Solution_{10} = _{L}T_{10} + _{L}T'_{9} + _{R}S_{10} + Z_{1} + Z_{2} + Z_{5} + ... + Z_{8} + Z_{9} + _{L}T'_{10}

The last Z_{9} and _{L}T'_{10} can provide some more cancellation:

Z_{9} + _{L}T'_{10} = ( _{L}S_{8} + _{R}S'_{8} + _{R}T'_{8} + _{L}T_{8}) + (_{L}T_{9} + _{L}S'_{8} + X + _{L}T_{8})'

= _{L}S_{8} + _{R}S'_{8} + _{R}T'_{8} + _{L}T_{8} + _{L}T'_{8} + X + _{L}S_{8} + _{L}T'_{9}

= _{L}S_{8} + _{R}S'_{8} + _{R}T'_{8} + X + _{L}S_{8} + _{L}T'_{9}

The idea behind this solution is that as soon as you have the largest blue piece in its correct place, you first fix the remaining blue ones above it. It is easier to do that first, separating the colours, because the orange tower can be built afterwards in its correct place without disturbing the blue pieces.

Given also that Z_{1} is one move, and Z_{2} seven, this leads to the following table:

n | S_{n} | T_{n} | Z_{n} | Sum Z_{n} | Solution |
---|---|---|---|---|---|

1 | 3 | 1 | 1 | 1 | |

2 | 8 | 3 | 7 | 8 | 16 |

3 | 23 | 9 | 22 | 30 | 50 |

4 | 59 | 24 | 64 | 94 | 140 |

5 | 146 | 60 | 166 | 260 | 366 |

6 | 356 | 147 | 412 | 672 | 922 |

7 | 863 | 357 | 1006 | 1678 | 2276 |

8 | 2087 | 864 | 2440 | 4118 | 5556 |

9 | 5042 | 2088 | 5902 | 10020 | 13486 |

10 | 12176 | 5043 | 14260 | 24280 | 32642 |

This improves on the previous method by more than 30%. The best known solution uses this method, shortened slightly by some more simplifications and cancellations. It still uses 31537 moves, and that solution method has been proved optimal by computer search.

**Solving any position**

Given that the solution is so long, it is quite likely that at some point you will lose track of where you were in the solution. It is possible to deduce what to do by examining where the largest pieces are, and then the next largest pieces, and so on. Of course, this assumes the pieces are distinguishable (i.e. the Panex Silver, not Gold). To do this, you must of course understand what route these pieces take during the solution. Let's first look at the largest blue piece.

- The large blue piece starts at the bottom of the left column.
- All the pieces above it on the left peg are removed (and piled up on the middle and/or right pegs).
- The large blue piece is moved to the middle peg, and slowly works its way down through the pieces of the middle peg, all the way until it is at the bottom.
- Now the largest other piece on the middle or right peg is freed up, and worked down the middle peg, until it is the only piece on the middle peg other than the large blue piece.
- The large blue piece swaps with that other piece, rising upwards a bit.
- Steps d and e are repeated with the second largest piece that can be found on the middle or right peg, then the next largest, and so on. The blue piece therefore bubbles upwards on the middle peg while all the other pieces from the right peg build up a tower underneath it.
- The blue piece then can be moved onto the empty right peg, to its solved position.