108 Ways To Do The Towers of Hanoi 192
hlarwood74 writes "While it is common to program in a few different languages, somebody has written "towers of hanoi" in 108 different ways, most of them in different programming languages. It's not just the number of languages though ... there are many neat implementations and in some cases he's come up with some strange ways of solving hanoi such as this: "you ping the hanoi machine with the number of disks encoded in the type of service field, and you get response packets whose sequence numbers represent the disk moves need to solve the puzzle". I wanted to ask "why" but the title of the page (hanoimania) explains a few things :)"
Re:Isn't there a legend involved? (Score:5, Informative)
Re:Isn't there a legend involved? (Score:5, Informative)
With 3 poles, you need (2 ^ discs)-1 moves to solve the problem. With 64 disks, and one move per second it's more like 584 billion years.
Re:Reminds me of... (Score:3, Informative)
Or you can download the archive [kernelthread.com]
Re:Isn't there a legend involved? (Score:2, Informative)
Re:Why is the C++ version so complex... (Score:2, Informative)
I'm glad he did it this way. I had heard of a previous student that programmed it non-recursively. Now I have an example to look at.
Re:Isn't there a legend involved? (Score:5, Informative)
When n is the number of disks:
The recurrence is T(n) = 2*T(n-1) + 1. (No, there isn't a faster way)
The function is T(n) = 2^n - 1
I can't quote the exact value of 2^64-1 offhand, but the maximum value of an unsigned 64-bit integer is definately pretty huge.
Re:Isn't there a legend involved? (Score:1, Informative)
Re:Haskell? (Score:4, Informative)
the Common Lisp version doesn't work (Score:3, Informative)
The person that wrote it sure did not have a firm grasp of Lisp. The use of eval was completely bogus. In any case, eval takes one argument, not three.
This [known.net] is a better one that actually works. I would have posted it here in the comment, but you can't format code in slashdot.