Send Close Add comments: (status displays here)
Got it!  This site "creationpie.com" uses cookies. You consent to this by clicking on "Got it!" or by continuing to use this website.  Note: This appears on each machine/browser from which this site is accessed.
Towers of Hanoi
by RS  admin@creationpie.com : 1024 x 640


1. Towers of Hanoi
Towers of HanoiThe Towers of Hanoi problem is a simple problem whose solution is intractable. A tower of 3 is a simple exercise.

Change the 3 to 80 and the program will not finish even in 15,000,000,000 (15 billion) years!
The eager solution in Python would never finish. The lazy program would continue to return results as called for the next value.

2. Eager program
Here is the Python code [#1]
Here is the output of the Python code.
Towers of Hanoi
An "eager" program will run until every part of the program has run, even if not all parts are needed.

Change the 3 to 80 and the program will not finish even in 15,000,000,000 (15 billion) years!

3. Lazy program
Here is the Python code [#2]
Here is the output of the Python code.
Towers of Hanoi
A "lazy" program will compute each partial result as requested.

This program will print the moves, in order, as requested. If, however, an unbounded (practically infinite) number is requested, the program would never complete.

4. End of page

by RS  admin@creationpie.com : 1024 x 640