Generalised "Tower of Hanoi" Problem

The following programme implements three methods of solving the "generalised" Tower of Hanoi problem. This problem, like the classical one, consists in finding the optimal sequence of moves for transfering a number of disks between two posts, the only difference in the generalised setting is that the number of posts can be arbitrary.

The programme presents the results of the following three algorithms:

- exponential recursive algorithm that delivers optimal solution;
- Musa's quick heuristic algorithm that delivers near optimal solution and Musa's heuristic that speeds up the exponential search;
- Fuad and Anar's quick algorithm that claims optimality.

Download the following file, save it under the name hanoi.tar.bz2, extract files hanoi.cpp and hanoi.h using a tar/bzip2-compatible decompression utility.

On a Unix-like system, decompress using "tar xfj hanoi.tar.bz2". Once the files hanoi.cpp and hanoi.h have been decompressed and placed into the same folder, compile hanoi.cpp using either a GNU or Intel C++ compiler by running the command c++ hanoi.cpp -o "output file name" (or icc hanoi.cpp -o "output file name" if using an Intel C++ compiler.)

The programme is coded in ISO C++ and can be ported to non-UNIX platforms as well.