![]() |
Python
1.0
|
Towers of Hanoi. More...
Functions | |
def | Hanoi (n, from_, to_, by_) |
Hanoi Tower. More... | |
def | main (argv=None) |
Main function for testing. More... | |
Towers of Hanoi.
The Tower of Hanoi puzzle was invented by the French mathematician Edouard Lucas in 1883. The game consists of a tower of eight disks, initially stacked in increasing size on one of three pegs. The objective is to transfer the entire tower to one of the other pegs, by moving only one disk at a time, and never a larger one onto a smaller.
Recurrence: \(T(h) = 2T(h-1) + 1 = 2^{h} - 1 \to O(2^{h}).\)
def _09_hanoi.Hanoi | ( | n, | |
from_, | |||
to_, | |||
by_ | |||
) |
Hanoi Tower.
A game invented by the French mathematician Edouard Lucas in 1883.
n | number of disks. |
from_ | source peg. |
to_ | destination peg. |
by_ | intermediary peg. |
Referenced by main().
def _09_hanoi.main | ( | argv = None | ) |
Main function for testing.
argv | number of disks. |
References Hanoi(), and _01d_dec2bin.input.