Slashdot Mirror


108 Ways To Do The Towers of Hanoi

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 :)"

192 comments

  1. Next up: 108 ways to post the same story on /. by corebreech · · Score: 5, Funny

    nt

  2. Isn't there a legend involved? by 91degrees · · Score: 5, Funny

    When someone works out every single way to solve the problem, the towers will crumble to dust and the world will vanish

    1. Re:Isn't there a legend involved? by Bagels · · Score: 5, Informative

      No, when somebody completes the problem with 64 disks, the world will end. It's an exponential-time function (big O of N^2), so doing that would take an insanely long time. I once calculated this out - assuming you could move 1 disk per second, it would take about 5 billion years, which is very roughly the predicted remaining lifespan of the sun.

      --
      --- Bwah?
    2. Re:Isn't there a legend involved? by koali · · Score: 1

      I'm just experiencing a pretty hangover, so I could be wrong here, but N^2 is not exponential with regards to N...

    3. Re:Isn't there a legend involved? by Anonymous Coward · · Score: 0
      64 disks, the world will end. It's an exponential-time function (big O of N^2)

      Even if you run it on a 64-bit processor? Dammit. And I was going to buy that Opteron for solving the 64-disk problems.

    4. Re:Isn't there a legend involved? by ianezz · · Score: 4, Informative
      It's an exponential-time function (big O of N^2).

      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.

    5. Re:Isn't there a legend involved? by Colonel+Cholling · · Score: 2, Interesting

      Besides, if I remember the legend correctly, the disks were supposed to be moved at the rate of one per year. (They're heavy, ok?)

      --

      I am Sartre of the Borg. Existence is futile.
    6. Re:Isn't there a legend involved? by Bagels · · Score: 1

      Heh. I stand corrected - when I worked it out on my calculator, it came out to 5.849424174*10^11 years.

      --
      --- Bwah?
    7. Re:Isn't there a legend involved? by Artraze · · Score: 2, Informative

      True-ish, as that may be (64 disks with a move per second takes 585 billion years), computers can solve the puzzle much faster. A nanosecond per move is not entirely unreasonible, and a computer at that speed would have it solved in 585 years (namely, a billionth of the time ;).

    8. Re:Isn't there a legend involved? by ComaVN · · Score: 5, Insightful

      Of course, a mathematician can solve the puzzle in 5 minutes. He proves the algorithm will solve the puzzle in the end, and leaves the actual moving of the stones as an exercise for his readers.

      He then goes on to generalize the algorithm to support n-dimensional stacks.

      --
      Be wary of any facts that confirm your opinion.
    9. Re:Isn't there a legend involved? by daveq · · Score: 5, Informative

      n^2 is quadratic, not exponential ;)

      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.

    10. Re:Isn't there a legend involved? by Anonymous Coward · · Score: 1, Informative

      Which is 584x10^9, in other words 584 billion... Learn to read standard form!

    11. Re:Isn't there a legend involved? by Alsee · · Score: 1

      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

      Uhhh huh. And I'd like to see how that machine responds to a 255 in the type of service header. The response packets would Shashdot the entire universe till the end of time.

      -

      --
      - - You can't take something off the Internet! That's like trying to take pee out of a swimming pool.
    12. Re:Isn't there a legend involved? by Anonymous Coward · · Score: 0
    13. Re:Isn't there a legend involved? by strike2867 · · Score: 0

      Can you really say one disk per second? What if whenever the computer needed to move a certain amount of disks, it would just just remember that combination. For example when it moves 3, it stores the exact moves, and then when it moves the fourth it just copies the moves to move the 3. And so on. Be a bitch to implement, I cant think a good way off the top of my head. But I think this may be less than n^2 because for every move half of it would just be copied. Therefore time to move 2 disks would be 3. The time to move 3 disks (once the 2 has already been figured out) would be 6. Therefore the time function would be 3(n-1). Not sure if this is right, dont have time to think about it right now. Somebody disagree with me, because this seems to obvious.

      --

      Vote for new mod!!! Score:-2,Imbecile
    14. Re:Isn't there a legend involved? by Austerity+Empowers · · Score: 1

      Why do I think this should have been modded as "Funny"...

    15. Re:Isn't there a legend involved? by Rubyflame · · Score: 1

      Just because you remember how to do something does not mean you can do it in constant time. You are only allowed to move one disk at a time, so the total time is proportional to the number of moving operations. The number of moves is 2^n-1.

      As for figuring out the exact moves needed, that's easy, and does not affect the order of the time requirement. It's a recursive function: To move n disks from pile A to pile C, simply move N-1 from A to B, move 1 from A to C, and move N-1 from B to C. The special case is for one disk, in which case you just pick it up and move it.

      --

      All it takes is nukes and nerves.
    16. Re:Isn't there a legend involved? by Anonymous Coward · · Score: 0

      IIRC the legend was really that there are a bunch of monks solving the tower of hanoi problem with physical disks, and the universe will only end if they finish, not if someone else does it on a computer, so 1 second per operation is realistic.

    17. Re:Isn't there a legend involved? by ErikZ · · Score: 1

      Sheesh. And if you can do 584 moves per second, then you can do it in a billion years.

      What a simple problem.

      --
      Democrats or Republicans. They are both taking us to the same place and they are not afraid of us anymore.
    18. Re:Isn't there a legend involved? by strike2867 · · Score: 0

      If our goal is to just show a listing of all the moves, then remembering is the way to do it. My point is that if you remember how to move a certain number of disks, all you have to do is just copy that, and make the necessary adjustments in the list(not using stack list). Also create an array of nodes pointing to each place in the list. Make it quicker. BTW my point is once you have moved 63 disks. You would not have to do that again once you move the 64th disk, you already have it.

      --

      Vote for new mod!!! Score:-2,Imbecile
    19. Re:Isn't there a legend involved? by 91degrees · · Score: 1

      That's not the exact figure. Just an approximation. You only gave the first 8 digits

      Try: 18 446 744 073 709 551 615

    20. Re:Isn't there a legend involved? by Goldfinger7400 · · Score: 1

      Unfortunately it isn't. I just had to perform said task for my CS173 class. I guess maybe it could be funny, because now I can go up to anybody and say "133t3r than thou" or something...

    21. Re:Isn't there a legend involved? by Anonymous Coward · · Score: 0

      errr...quadratic. Exponential would mean having the n term as an exponent.

    22. Re:Isn't there a legend involved? by Anonymous Coward · · Score: 0
      computers can solve the puzzle much faster. A nanosecond per move is not entirely unreasonible, and a computer at that speed would have it solved in 585 years (namely, a billionth of the time ;).


      Shhhh, don't tell the monks that! They just might do that

    23. Re:Isn't there a legend involved? by Anonymous Coward · · Score: 0

      Or given the simplicity of the problem, on a quad 3ghz Xeon, it's safe to assume that 1 billion moves can be made per second (when hand coded in assembly with threading and no OS fo example), so theoretically, that system can handle it in under 10 minutes.
      Of course there are nice little unisys 32 way SMP Xeon systems at 3ghz, and 128 way Sparcs at 2ghz, and 1024 itanium 2 SGI systems etc... given current existing systems, it is theoretically possible that the problem can be solved in under 1 second.
      Maybe a 128 disc version would make things more interesting

    24. Re:Isn't there a legend involved? by icejai · · Score: 1
      It's an exponential-time function (big O of N^2).

      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.


      And don't forget, the monks are only allowed to move one disk per day.
    25. Re:Isn't there a legend involved? by Anonymous Coward · · Score: 0

      If our goal, as you say, is to just show a listing of all moves, then we have to print that listing. Printing is O(s), where s is the size of the output... each character has to be copied.

      In this case, the size of the list is 2^n-1, so generating and printing the entire listing is O(2^n).

      Even if you're just talking about building a list of moves without printing anything, we're still talking about O(n^2), because copying any part of that list is also an O(s) operation.

      Now you seem to be saying that we can "copy" portions of our move list by creating multiple pointers to the same part of the list, but that doesn't work, because we're not just copying a set of moves without altering it. The basic sequence is the same, but the stacks we're dealing with are different. For example, say we have three disks. They start on Stack A and we have to move them to Stack C, using Stack B as an auxiliary stack.

      our procedure looks like this:

      1. Move 2 from A to B
      2. Move 1 from A to C
      3. Move 2 from B to C
      (4. ? 5. Profit! yadda yadda)

      You seem to be suggesting that we create a list of the operations in step 1, then just point to that list for step 3, but this can't be done without modifying the list, because we have to change all instances of B to C and all instances of A to B.

      Sorry, but you should give these problems a bit more thought before you declare that everyone is doing it the wrong way.

  3. Reverse DOS? by Crypto+Gnome · · Score: 3, Interesting

    "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"

    ping HanoiServer -tos=128

    Send one packet, get a hundred thousand (I'm sure I lost count somewhere) in return?

    --
    Visit CryptoGnome in his home.
    1. Re:Reverse DOS? by Crypto+Gnome · · Score: 1, Funny

      Yea Yeah Yeah, I know the TOS field isn't big enough to show 128.

      It's a joke, so laugh.

      --
      Visit CryptoGnome in his home.
    2. Re:Reverse DOS? by Anonymous Coward · · Score: 0

      fear not for your hanoi ping server, for tos must be between 1 and 10 for it to respond with a solution.

    3. Re:Reverse DOS? by Anonymous Coward · · Score: 0

      Shut the fuck up, dick. If I ever meet you I'm going to smash your face up until even your mother couldn't recognise it.

    4. Re:Reverse DOS? by Anonymous Coward · · Score: 0

      if you can reach past your teeth, englishturd.

  4. Whitespace? by hkroger · · Score: 5, Interesting

    Hmm, not all the important languages are represented in the list. I didn't see e.g. whitespace implementation.

    1. Re:Whitespace? by FrostedWheat · · Score: 5, Funny

      Maybe they did, but you just didn't see it?

    2. Re:Whitespace? by ObviousGuy · · Score: 2, Funny

      I have discovered a truly marvelous demonstration of this proposition and have encoded it here in Whitespace.

      --
      I have been pwned because my /. password was too easy to guess.
    3. Re:Whitespace? by rasteroid · · Score: 1

      No LISP either :(

    4. Re:Whitespace? by Anonymous Coward · · Score: 0

      Whitespace... whatever.

      There is no LISP! A recursive problem with no LISP implementation. AAAAAAAAAAAAAAAAAA!

    5. Re:Whitespace? by jnana · · Score: 1

      Ummm, there is a Common Lisp implementation: <a href="http://www.kernelthread.com/hanoi/html/gcl.h tml">http://www.kernelthread.com/hanoi/html/gcl.ht ml</a>, but it's getting slashdotted right now.

    6. Re:Whitespace? by spamguy · · Score: 0

      I noticed. Also, I'm rather hurt that they didn't include APL. Not including it is like disregarding ancient Roman history because they spoke a dead language. What's wrong with scanning in a punch card or two?

  5. My addition by kinnell · · Score: 5, Funny

    Here it is coded in Whitespace:





    --
    If I seem short sighted, it is because I stand on the shoulders of midgets
    1. Re:My addition by ShootThemLater · · Score: 5, Funny

      Hmmm, looks like slashcode's added a couple of extra whitespaces in there. Won't compile.

  6. But what about... by Mr.+Mosty-Toasty · · Score: 3, Funny

    ...Brainfuck?

    1. Re:But what about... by Doc+Squidly · · Score: 1

      I thinks it on the site as "Brain". But, the link was broken.

      --
      I think I think, therefore I think I am.
    2. Re:But what about... by Vess+V. · · Score: 1

      That's peanuts, here's DeCSS in Brainfuck.

  7. pfff ... Big deal ... by cablepokerface · · Score: 5, Funny

    Converting the Towers of Hanoi syntax into 108 different languages?

    Visual Studio.NET includes a standard wizard for that.

    1. Re:pfff ... Big deal ... by Gr8Apes · · Score: 1

      adding random crap is not a language....

      --
      The cesspool just got a check and balance.
  8. Overpriced, proprietary crap by Anonymous Coward · · Score: 0

    I hope you and your piece of overpriced proprietary slow-as-molasses crap will be happy together.

  9. Reminds me of... by zhenlin · · Score: 4, Insightful

    http://www2.latech.edu/~acm/HelloWorld.shtml

    The Hello World page.

    The difference? The examples on the Hello World page all have source code. Hanoimania... Not so.

    But.... solving the Towers of Hanoi shows a lot more of the programming environment than Hello World does... Conditionals, branching, recursion, function calls...

    1. Re:Reminds me of... by edalytical · · Score: 3, Informative
      You can view the source code if you click on the name of the language in the section of the page labeled: "The Implementations"

      Or you can download the archive

      --
      Win a signed Stephen Carpenter ESP Guitar from the Deftones: http://def-tag.com/?r=0008781
    2. Re:Reminds me of... by Anonymous Coward · · Score: 0

      > The examples on the Hello World page all have source code. Hanoimania... Not so.

      Which languages are missing the source code then?

    3. Re:Reminds me of... by zhenlin · · Score: 1

      The keyword here is all.

      The page clearly states that there are 4 for which there is no source code.They are:

      * Hanoi OS for SPARC
      * Sun Solaris /proc
      * Sun Solaris STREAMS
      * Sun Solaris kernel module

      Curious, isn't it, that they are all related to Sun?

    4. Re:Reminds me of... by Gorobei · · Score: 5, Interesting

      The first one I checked (Common Lisp,) was just wrong:

      (defun dohanoi(n to from u)
      (if (> n 0)
      (eval
      (dohanoi (- n 1) u from to)
      (format t "move ~D --> ~D~&" from to)
      (dohanoi (- n 1) to u from)
      )
      )
      )

      (defun hanoi(n)
      (eval
      (dohanoi n 3 1 2)
      )
      )

      eval is not what we want here (it evaluates a single form in the current dynamic environment.) Also, we can use 1- and indent trailing parens correctly. For extra credit, we could make dohanoi local to hanoi.

      (defun dohanoi(n to from u)
      (when (> n 0)
      (dohanoi (1- n) u from to)
      (format t "move ~D --> ~D~&" from to)
      (dohanoi (1- n) to u from)))

    5. Re:Reminds me of... by edalytical · · Score: 2, Interesting
      The keyword here is all.
      Indeed, the keyword is all.

      http://www2.latech.edu/~acm/HelloWorld.shtml

      Is missing:

      BLISS
      Cecil
      Demeter
      Elf
      Escher
      Hope
      Infer
      NESL
      Obliq
      Proteus
      SGML
      Sisal
      Theta
      Tycoon
      emacs
      Lotus 1,2,3
      Unisys' WFL
      OWL
      MFC
      ZApp
      Zinc

      And those are just the languages listed that don't have a link at the Hello World! page http://www2.latech.edu/~acm/HelloWorld.shtml

      --
      Win a signed Stephen Carpenter ESP Guitar from the Deftones: http://def-tag.com/?r=0008781
  10. X11? by mr100percent · · Score: 1

    So which one of these should I run if I want to view it animated in X11?

    1. Re:X11? by Takara · · Score: 1

      That would be the Hanoi Xlib version.

  11. What? No Intercal? by dm(Hannu) · · Score: 0, Funny

    No language comparison is complete without Intercal.

    1. Re:What? No Intercal? by edalytical · · Score: 1

      PLEASE GIVE UP No one said it was complete.

      --
      Win a signed Stephen Carpenter ESP Guitar from the Deftones: http://def-tag.com/?r=0008781
  12. Re:what if he had spent his time on something usef by Anonymous Coward · · Score: 0

    Actually, as a geek I agree with this post.

    If we banded our collective talents together we could produce things much more useful than Hanio ICMP servers and blue LED case mods. Such as world peace or cost-effective nuclear fission.

    After all, geeks are more intelligent than other people. Our failing is our inability to socialise coherently.

  13. Re:Teh BUTTSECHS by Anonymous Coward · · Score: 0

    Try Austria in Vienna. That is, without a doubt, the gay capital of Europe.

  14. yeah... by AbbyNormal · · Score: 5, Funny

    to the joy of millions of 1st year Computer Science students.

    --
    Sig it.
    1. Re:yeah... by cdrudge · · Score: 3, Funny

      And much to the chagrin of thousands of CS profs.

    2. Re:yeah... by paul248 · · Score: 1

      IAAFYCSS, and that happened to be my favorite lab :-)

    3. Re:yeah... by JustAnotherReader · · Score: 1
      But think of how convenient it will be every September when the new CS students start posting their questions to various news groups with subject lines like :

      Need Help ASAP! How Do I Do This??!!

      Now we can just point them to this page and ignore them istead of trying to explain how we're not here to do their homework for them. Ah, yes. The changing color of the leaves, the crisp coolness of the air, the desperate plea of the programmer newbies. Those are the first signs of autumn that I love so much.

  15. Re:what if he had spent his time on something usef by mo26101 · · Score: 5, Insightful

    This is useful to him, RTFA.
    In fact, while this has gone to an extream, a many developers have a pet progam they implement anytime they run across a new language/platform. This give the programmer a familiar program to implement in an unfamiliar environment. A great way to get your feet wet with something new. Whenever I start working with a new language or on a new platform, I have a game I implement that covers many of the basic program constructs. By the time I have finished the game I have a good enough working knowledge of teh new language and/or platform to begin some real work.

    Here is the same basic explination from the web page (I am assuming it will get slashdotted soon):

    I am often asked that since I do all this, whether I have a lot of free time on my hands. Between my work and my interests (both of which overlap to a great extent), I actually have no free time. As an aside, I would not (and should not) be expected to "know" so many programming languages, and I don't think I do! However, I do believe that knowing a computer language is a rather fuzzy idea. If one could write a useful (loosely speaking, again) program in a given language, it is instructive to question whether one knows it. It is ironical (yes, there is such a word) that the bigger challenge, at least in my opinion, lies not in writing programs in all these different languages and ways, but in rapidly setting up the respective compiler systems and/or development environments on an appropriate platform/operating system. Sometimes compilers, interpreters and other such software for a particular language may be readily available, and run "out of the box", but many times this is not the case. Sometimes it turns out to be a non-trivial problem to get a compiler to function (pun unintended). Of course, once you get past this, you do have to understand some subset of the language!

  16. Why is the C++ version so complex... by Viol8 · · Score: 4, Interesting

    ...when the C version is so simple? He could have used the C version for both. Even if he was trying to show off the features of the
    language the C++ version is still way overkill.

    1. Re:Why is the C++ version so complex... by oe1kenobi · · Score: 2, Informative

      Because the C++ version is non-recursive.

      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.

      --
      -Richard L. Owens
    2. Re:Why is the C++ version so complex... by Anonymous Coward · · Score: 0

      Because he wrote his own stack class. He could have used std::stack and saved himself a fair bit of work.

    3. Re:Why is the C++ version so complex... by Anonymous Coward · · Score: 0

      It's not complex until it's implemented in templates and with the solution calculated at compile-time.

    4. Re:Why is the C++ version so complex... by musikit · · Score: 1

      my question is why he made his own stack object. i could have sworn the STL has a stack object included.

    5. Re:Why is the C++ version so complex... by fnj · · Score: 2, Interesting

      my question is why he made his own stack object. i could have sworn the STL has a stack object included.

      Er, just a guess, but maybe the original concept of his code predated the wide availability of STL. Or quite likely, as a tutorial, he just wanted to depend on nothing beyond iostreams.

      I'm more concerned with some other points:

      Why "#define STYPE int" instead of "typedef int stype"?

      Why the #defines for EMPTY, FULL, and PUSH_OK instead of an enum?

      Why the "Stack::Stack(void)" instead of just "Stack::Stack()" (the former is a C anachronism)?

      Then, of course, to get really nitpicky, he doesn't need his destructor at all (one will be generated by the compiler).

    6. Re:Why is the C++ version so complex... by musikit · · Score: 2, Interesting

      very true. i guess it goes to another comment that someone else had about writing code in C and it being compilable in C++. while true there are different ways your suppose to write C++ code vs. C code. however it seems a large amount of people use a mix. Or maybe no one is teaching people to program in C++ but in C with C++ constructs.

    7. Re:Why is the C++ version so complex... by ahrenritter · · Score: 1

      His non-recursive C++ version is rather bogus. It works, but it is recursive, it is just taking the stack out of the hands of the compiler and managing it himself. Take a look at some of the cyclic answers in other comments here for a very nice non-recursive version.

      --

      All I wanted was a rock to wind a piece of string around, and I ended up with the biggest ball of twine in Minnesota
    8. Re:Why is the C++ version so complex... by Pseudonym · · Score: 1
      Why the #defines for EMPTY, FULL, and PUSH_OK instead of an enum?

      Probably because CAPACITY is too, and CAPACITY is a macro because this was probably written before static const ints could be used as array size initialisers.

      Presumably this also explains why he didn't use exceptions instead of EMPTY/FULL/PUSH_OK. There's no excuse for the variables starting with underscores, though.

      OK, here's my version.

      --
      sub f{($f)=@_;print"$f(q{$f});";}f(q{sub f{($f)=@_;print"$f(q{$f});";}f});
  17. Haskell? by mattr · · Score: 3, Insightful

    Is it just me or does the Haskell one seem to have inverted parameters wrt the vanilla Perl one? Not that I know Haskell.. I was hoping to see some lexical wierdness in Perl and some lambdas and arrows all hanging out for the Haskell one. And wha-hey no smalltalk? well the world goes on..

    Neat idea, I like to see how things are done in other languages. It would be an interesting and intuitive way to show people what other languages are like, a list of programs the same in each language, plus commentary about the highlights of the language that are used.

    1. Re:Haskell? by twoshortplanks · · Score: 1
      The Perl one's really weird
      ($#ARGV == 0) or die "usage: $0 N\n";
      Wow, that's really confusing. It's trying to say unless we've got arguments, we need to die with an error message. Which can be witten as
      unless (@ARGV)
      { die "usage: $0 N\n"; }
      That's not the only other thing that's odd too. Using local instead of my is odd - though both will work. my will do proper lexical variables, whereas local is using main variables in the stash and creating temp copies each itteration of the subroutine.

      Oh, and wrapping the whole thing in a if statement is odd. You should just return if you're the base case (just like you do with tail recursion in Haskell)

      Here's a cleaned up version with comments

      #!/usr/bin/perl

      # turn on perl's safety features
      use strict;
      use warnings;

      # check we got some arguments
      unless (@ARGV)
      { die "usage: $0 N\n" };

      # get the number of disks
      my $N = int($ARGV[0]);
      unless ($N > 0)
      { die "$0: illegal value for number of disks\n";}

      # run the main routine
      hanoi($N, 3, 1, 2);

      sub hanoi
      {
      my ($num_disks, $to_peg, $from_peg, $using_peg) = @_;

      # are we done? (i.e. is this the basecase)
      return unless $num_disks;

      # move the stack covering the 'bottom' disk to the
      # spare peg
      hanoi($num_disks-1, $using_peg, $from_peg, $to_peg);

      # move the 'bottom' disk to the other stack
      print "move $from --> $to\n";

      # move the stack we moved to the spare peg ontop
      # of the disk we just moved.
      hanoi($num_disks-1, $to_peg, $using_peg, $from_peg);
      }
      Note that one of the first things I did was turn strict and warnings on, thus meaning it's easier to catch mistakes.

      Wow, ECODE doens't let you space things in properly. That's terrible.

      --
      -- Sorry, I can't think of anything funny to say here.
    2. Re:Haskell? by twoshortplanks · · Score: 1
      whoops, the $from and $to should be $from_peg and $to_peg, obviously.

      d'oh.

      Yes, if I'd run that perl would have complained at me because use strict was on.

      --
      -- Sorry, I can't think of anything funny to say here.
    3. Re:Haskell? by Anonymous Coward · · Score: 0

      Here's a program using more orthodox Haskell. The functions are
      uncurried, it has static function types and it uses an accumulating
      parameter instead of the (++) operator for efficiency ((++) is linear
      in its left argument - although since Hanoi is an exponential
      algorithm, this streamlining makes next to no difference!).

      > dohanoi :: Int -> Int -> Int -> Int -> [(Int,Int)] -> [(Int,Int)]
      > dohanoi 0 _ _ _ accum = accum
      > dohanoi n from to using accum =
      > dohanoi (n-1) from using to
      > ((from, to):(dohanoi (n-1) using to from accum))

      > hanoi :: Int -> [(Int,Int)]
      > hanoi n = dohanoi n 1 3 2 []

      Compare to the original:

      > dohanoi(0, _, _, _) = []
      > dohanoi(n, from, to, using) = dohanoi(n - 1, from, using, to)
      > ++ [(from, to)] ++
      > dohanoi(n - 1, using, to, from)

      > hanoi(n) = dohanoi(n, 1, 3, 2)

    4. Re:Haskell? by Anonymous Coward · · Score: 4, Informative

      "(condition) or die" is perfectly good, non-confusing Perl. It's the way you're told to do it in the Camel book, for God's sake.

    5. Re:Haskell? by Anonymous Coward · · Score: 0

      The functions are uncurried

      Er, no, the functions in your version are curried. It's his version that uses uncurried functions, which is an abomination in FP, since it prevents partial application.

    6. Re:Haskell? by Anonymous Coward · · Score: 0

      It'd only take a line of perl to solve the tower of hanoi problem so it's not really interesting enough to post.

    7. Re:Haskell? by twoshortplanks · · Score: 1
      There's more than one way to it.

      ;-)

      --
      -- Sorry, I can't think of anything funny to say here.
    8. Re:Haskell? by Anonymous Coward · · Score: 0

      Oops, quite right. I meant curried!

  18. Re:what if he had spent his time on something usef by johannesg · · Score: 4, Funny

    ...he said in a posting on slashdot.

  19. Re:what if he had spent his time on something usef by MooCows · · Score: 1

    I think we have recursion going on here.

    --
    The path I walk alone is endlessly long.
    30 minutes by bike, 15 by bus.
  20. Missed a language by karlandtanya · · Score: 1
    Relay Ladder Logic


    You can program anything in RLL. Not that you'd want to--but your Client probably wants you to.

    --
    "Reality is that which, when you stop believing in it, it doesn't go away." - Philip K. Dick
    1. Re:Missed a language by tzanger · · Score: 1

      You can program anything in RLL. Not that you'd want to--but your Client probably wants you to.

      Amen to that... How I loathe PLCs... ugh.

    2. Re:Missed a language by Anonymous Coward · · Score: 0

      Gahhhh!

      Damn you for giving me flashbacks to my days at Reliance Electric -- Programming in ladder logic and BASIC filled many of my days there...

  21. Re:what if he had spent his time on something usef by princewally · · Score: 1

    Our failing is our inability to socialise coherently

    Which would be a large part of what makes us geeks.

    --

    -
    "Vengeance is fine," sayeth the Lord.
  22. Do not forget MetaPost by Anonymous Coward · · Score: 0

    I did this in MetaPost a few months ago. Check out my posting in comp.text.tex.

  23. Multi-user 3D by mst · · Score: 1

    I once did a 3D-visualized Prolog implementation of the towers of Hanoi for a course assignment. It used the VR system DIVE for visualization, the Hanoi implementation was a simple proof of concept of the rudimentary Prolog interface to DIVE that was the actual assignment... Sweet memories :)

    (Un?)fortunately, the code is not publicly available.

  24. What is the most disks you have solved for? by fliptout · · Score: 2, Interesting

    I've solved the towers of hanoi with 8 disks.. Curious if anyone has solved a more insane number without computer assistance.

    Though it seems pretty pointless and boring to solve for a high number of disks as the learning curve drops sharply after you figure out how to solve for the basic three disks.

    --
    A witty saying proves you are wittier than the next guy.
    1. Re:What is the most disks you have solved for? by sprprsnmn · · Score: 1

      As a younger child, a teacher would give this problem to "gifted" students who were bothering her. We couldn't ask another question until we solved it, with 10 disks.

    2. Re:What is the most disks you have solved for? by fbform · · Score: 3, Funny

      Eight here too. In fact when I first heard of the problem (when I was 10 I think), it specified 8 disks. Never occurred to me to solve for a smaller problem first. It took me some 14 months to find a solution for the 8-disk problem by myself. Man, those were the days! I used playing cards instead of disks, and everybody around me thought I was playing some weird form of Solitaire. Sigh.
      Yes, I'm still single. Why do you ask?

      --
      Time flies like an arrow. Fruit flies like a banana.
    3. Re:What is the most disks you have solved for? by jtdubs · · Score: 2, Funny

      10 here. i wrote a computer program to draw a sexy 3d version of it and let me move pieces by tapping the 1, 2 and 3 keys. after solving 4 or 5 discs a few times my fingers would get into this wierd zone where they'd just fly over those three keys without any conscious thought. very cool.

      justin

  25. not that you need recursion for this... by johntromp · · Score: 2, Interesting

    max = 1 no_of_discs;
    for (x = 1; x max; x++)
    printf("move a disc from %d to %d\n", (x&x-1)%3, ((x|x-1)+1)%3);

    1. Re:not that you need recursion for this... by johntromp · · Score: 1

      /* oops, forgot to format as code.
      it should've looked like:
      */

      max = 1 << no_of_discs;
      for (x = 1; x < max; x++)
      printf("move a disc from %d to %d\n", (x&x-1)%3, ((x|x-1)+1)%3);

  26. yet another missing language by Savatte · · Score: 1

    where is the quakec implementation? This would make quite the interesting demonstration.

  27. And the 109th way... with a guitar by Hornsby · · Score: 1

    http://www.towersofhanoi.org

    --
    A musician without the RIAA, is like a fish without a bicycle.
  28. My favourite by vorwerk · · Score: 5, Interesting
    A quick scan of the listing didn't show my favourite one -- a non-recursive implementation.
    #include <stdio.h>

    #define NO_OF_DISKS 4

    void main()
    {
    int max, x;

    max = 1 << NO_OF_DISKS;
    for (x = 1; x < max; x++) {
    printf("Move a disc from %d to %d\n", (x&x-1)%3, ((x|x-1)+1)%3);
    }
    }
    1. Re:My favourite by akuzi · · Score: 1

      This algorithm has a slightly different result from the recursive algorithm.

      For an even number of disks it your code moves the disks from stack 0 to 1, and for an odd number of disks from stack 0 to 2.

      (The recursive algorithm in the 102 examples moves the disks from stack 0 to 2 always).

  29. Re: your sig by dillon_rinker · · Score: 0, Offtopic

    A musician without the RIAA, is like a fish without a bicycle.

    Try this...A musician without the RIAA is like a fish without a hook.

    The RIAA is actually harmful. The original quote suggested simply that women didn't need men. (Also that women were slimy scaly smelly creatures and men were carefully engineered tools of great craftsmanship, but I digress...)

  30. Re:what if he had spent his time on something usef by Anonymous Coward · · Score: 0

    Yeah, God forbid that a geek ever try to have fun.

  31. Towers of hanoi and bit flip correlation by nebaz · · Score: 5, Interesting

    One neat thing I discovered about the towers of hanoi is that the sequence of disks to move for a solution

    1,2,1,3,1,2,1,4,1,2,1,3,1,2,1,5...
    is the exact same sequence that you get when you look at the number of bits flipped between consecutive binary numbers (i.e.
    00000->00001 (1 flip),
    00001->00010 (2 flips),
    00010->00011 (1 flip),
    00011->00100 (3 flips),
    00100->00101 (1 flip),
    00101->00110 (2 flips)
    etc... (1,2,1,3,1,2,...)

    The reason it works is because just like the towers of hanoi algorithm, when the general solution to move n disks is:
    Recursively solve the puzzle for n-1 disks
    Take the nth disk and move it to the goal
    Recursively solve the puzzle for n-1 disks.

    The bit flipping goes like this:
    While the nth bit is 0, the solution works for the n-1 disk solution
    When we go from 011111 (n-1 1's) to 10000000 (n-1 0's) we flip n bits
    Then the nth bit stays 1 and we repeat the solution for the n-1 disks.

    --
    Rhymes that keep their secrets will unfold behind the clouds.There upon the rainbow is the answer to a neverending story
    1. Re:Towers of hanoi and bit flip correlation by kallisti · · Score: 1
      The Chinese rings puzzle is also based on the binary numbers. I have a puzzle called "The Brain" with rods that slide in and out. These are all really the same puzzle and have the same solution:

      Alternate moving the smallest ring and doing the only other move left.

      The only problem is that you need to go in the correct direction at the beginning, otherwise you're moving an odd number instead of even or vice-versa. I got to where I could solve the Brain (8 sliders) in a few seconds with my eyes closed.

    2. Re:Towers of hanoi and bit flip correlation by anonymous+moderator · · Score: 1

      Equivalently, but perhaps more simply, note that the prime factorization of n includes 2^m where...

      n 1 2 3 4 5 6 7 8
      m 0 1 0 2 0 1 0 3

      i.e. the same sequence offset by one. It is easy to see why they are equivalent. This sequence comes up often... the one I listed above and the two that you listed are the most common ones that I had found so far.

    3. Re:Towers of hanoi and bit flip correlation by nebaz · · Score: 1

      They are equivalent for the same reason. This sequence (ultimately) can be expressed in terms of the recurrence
      Seq(n) = Seq(n-1) + single sequence value for ("n") + Seq(n-1).

      Which is true both in the hanoi, and bit flip example

      In the example of prime factorization let k=2^n, and l<k be an integer. If we factor l as
      l=2^m * p, with m<n and p odd, then we can "shift" the sequence generated with (1..k-1) to
      (1+(k), (k-1)+k) because if l = 2^m * p then
      k+l = 2^m * p + 2^n = 2^m (p + 2 ^(n-m)), with (p + 2 ^(n-m)) odd. Thus the sequence for n-1 repeats right after the nth term shows up.

      The only difference between this sequence and the first two is that "single sequence value for "n" is actually n-1 instead of n.

      --
      Rhymes that keep their secrets will unfold behind the clouds.There upon the rainbow is the answer to a neverending story
  32. Representative? by lpret · · Score: 1
    Now here's a question:

    Do you think that this problem is representative of the language? e.g. Perl is more efficient than PHP. Or is this going about it all wrong because of the specialisation of programming? Perhaps a series of tests consisting of different types of problems would be possible?

    --
    This is my digital signature. 10011011001
  33. XML/XSL by Chilltowner · · Score: 5, Interesting

    As an XSL guy, I felt left out. So, given this xml:
    <?xml version="1.0"?>
    <hanoi>
    <arg n="3"/>
    </hanoi>

    you can transform with this:
    <?xml version="1.0"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:template match="/">
    <xsl:variable name="n">
    <xsl:value-of select="//arg/@n"/>
    </xsl:variable>
    <xsl:element name="hanoi-solve">
    <xsl:call-template name="dohanoi">
    <xsl:with-param name="n" select="number($n)"/>
    <xsl:with-param name="to" select="3"/>
    <xsl:with-param name="from" select="1"/>
    <xsl:with-param name="using" select="2"/>
    </xsl:call-template>
    </xsl:element>
    </xsl:template>
    <xsl:template name="dohanoi">
    <xsl:param name="n"/>
    <xsl:param name="to"/>
    <xsl:param name="from"/>
    <xsl:param name="using"/>
    <xsl:if test="number($n) &gt; 0">
    <xsl:call-template name="dohanoi">
    <xsl:with-param name="n" select="number($n) - 1"/>
    <xsl:with-param name="to" select="$using"/>
    <xsl:with-param name="from" select="$from"/>
    <xsl:with-param name="using" select="$to"/>
    </xsl:call-template>
    <xsl:element name="move">
    <xsl:attribute name="from">
    <xsl:value-of select="$from"/>
    </xsl:attribute>
    <xsl:attribute name="to">
    <xsl:value-of select="$to"/>
    </xsl:attribute>
    </xsl:element>
    <xsl:call-template name="dohanoi">
    <xsl:with-param name="n" select="number($n) - 1"/>
    <xsl:with-param name="to" select="$to"/>
    <xsl:with-param name="from" select="$using"/>
    <xsl:with-param name="using" select="$from"/>
    </xsl:call-template>
    </xsl:if>
    </xsl:template>
    </xsl:stylesheet>

    1. Re:XML/XSL by Anonymous Coward · · Score: 0

      For God's sake I you XML people carry condoms just in case.

  34. Do It in Hardware by 4of12 · · Score: 2, Interesting

    I remember decades ago coming across the towers of Hanoi built with wooden dowels and hardwood disks with holes in them. This was late one evening when everyone else had retired.

    After playing around with it for a few minutes, my mind just naturally got into the algorithm. The disks were flying around with hardly any conscious thought required on my part.

    Just one of those cool game zombie states...

    Probably because I'm prone to addictive behaviors I tend to avoid getting involved too closely with games; but I still remember the great buzz of doing Towers of Hanoi the first time.

    [There's another hardware puzzle, like a Chinese lock with multiple loops, that's similarly fun for the recursively minded.]

    --
    "Provided by the management for your protection."
  35. the Common Lisp version doesn't work by e40 · · Score: 2, 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 is a better one that actually works. I would have posted it here in the comment, but you can't format code in slashdot.

    1. Re:the Common Lisp version doesn't work by Anonymous Coward · · Score: 0

      the bootable x86 hanoi OS doesn't compile. i get some errors about the clock and something about a phase error at the end of the file. and there is no image in the archive as was stated.

    2. Re:the Common Lisp version doesn't work by Anonymous Coward · · Score: 0

      Works for me.

  36. Very easy non-recursive solution by OttoM · · Score: 4, Insightful
    This solution I always liked best:

    Imagine the disk are in a cricle. Repeat:

    1. move the smallest disk one step clockwise
    2. do the only legal move not involving the smallest disk
    Much easier to remember and perform by hand than the various iterative C programs posted. The proof that it works is left as an exercise to the reader...
  37. More interesting by codemachine · · Score: 1

    The guy's Resume says that he works on Linux on the Desktop at IBM's research lab.

    Interesting to see IBM working with Linux on the Desktop at all.

  38. Combsort in a few languages by WayneConrad · · Score: 1, Interesting

    Gravatite and I like to code Combsort when we're learning a new language. Combsort a very simple modification to bubblesort that makes it competative with Quicksort but without quite as much complexity -- it's good for those rare occasions where you have to hand-code a sort and don't need all the fuss of quicksort.

    I've done combsort in about a dozen dozen languages, and Gravatite has done it in a few more languages, including postscript.

  39. He ain't using a tower though... by Erik+K.+Veland · · Score: 1

    His page also contains the best review of a PowerBook 17" that I've ever read.

    --
    "I tend to think of OS X as Linux with QA and Taste", James Gosling, creator of Java
  40. I'm surprised no one has suggested... by EvilLile · · Score: 2, Funny
    Malbolge. Who ever said programming was supposed to be easy or fun?

    Malbolge, Programming From Hell

  41. That C++ version sucks. by pclminion · · Score: 3, Interesting

    That's the worst C++ feature-masturbation I've ever seen.

    Here's a version using C++ template metaprogramming I just whipped up:

    #include <iostream>

    template <int N, int From, int To, int Using>
    class HanoiSolver
    {
    public:
    static void solve()
    {
    HanoiSolver<N-1, From, Using, To>::solve();
    std::cout << "Move " << From << " to " << To << std::endl;
    HanoiSolver<N-1, Using, To, From>::solve();
    }
    };

    template <int From, int To, int Using>
    class HanoiSolver<0, From, To, Using>
    {
    public:
    static void solve()
    {
    }
    };

    int main()
    {
    HanoiSolver<10, 1, 2, 3>::solve();
    }

  42. When I read the title.. by Anonymous Coward · · Score: 1, Funny

    I thought of 108 Ways To Do The Girls of Hanoi.

    Much more, uh, arousing.

  43. Black & White by sgumby · · Score: 1

    at one moment of the game, you have to resolve this kind of problem in Black & White.

    1. Re:Black & White by Doc+Squidly · · Score: 1

      Really? All I did in that game was teach my Creature to throw his feces at the villagers.

      --
      I think I think, therefore I think I am.
  44. Not really non-recursive by darkonc · · Score: 2, Interesting
    His "non-recursive" solutions aren't really non-recursive. They simply store the state (what's being moved where) onto the stack, and then pulls and pops the state. It's just a simple enough 'machine' that you only have 4 variables (from, to, using, depth). All you've really done is taken the stackwork away frm th compiler.

    Back in the late '70s, me and some friends came up with a solution that is more honestly non-recursive:

    Move the smallest disk to the right (cyclically). If the other two stacks are empty, you're done, else move the smallest top disk of the two stacks to the other stack (the only move you can make if you're not moving disk 1 again).

    (note: The above solution only works for an even number of disks... For an odd number of disks, disk 1 moves to the LEFT.)

    Oh, sigh... The perl implementation of this is on my website.

    Yes, the solution is provably correct, but I don't have the time to write it up right now... Just consider the fact that you can never move disk1 twice in a row, (or you're wasting a move), and if you're not moving disk1, there's only one move, then you have to move disk1 again (or you're wasting a move). All you have to do then is prove that disk1 always moves in the same direction.

    --
    Sometimes boldness is in fashion. Sometimes only the brave will be bold.
  45. Towers of Hanoi in KOTOR by harborpirate · · Score: 1

    Ok, I know its slightly offtopic...

    Its true, the towers of Hanoi puzzle is actually present in the Star Wars: Knights of the Old Republic game. Its the 4 disk version.

    Always fun to see classic puzzles show up in computer games under a different guise.

    --
    // harborpirate
    // Slashbots off the starboard bow!
  46. Good god! by Billly+Gates · · Score: 1
    108 versions??

    Not to sound trollish but, this guy has way too much time on his hands and needs to get a life, or find something interesting to program.

    Maybe its just me but I get nightmares from Tower of Hanio programs.

    Its what made me decided that Biology and not CS is where I belonged.

    Shudder.

  47. Parasitic Computing by Anonymous Coward · · Score: 0

    Using other computers to solve NP-hard problems without their knowledge is called Parasitic Computing. It involves using the normal IP-checksum feature to encode the problem as the data part and the solution as the checksum, with the property that the checksum matches only if it is the correct solution to the problem. An article appeared in Nature about this sometime back and it can be found here:

    http://www.nd.edu/~parasite/

  48. Comment removed by account_deleted · · Score: 1

    Comment removed based on user account deletion

  49. One more port he missed... by drdreff · · Score: 1

    Laszlo LZX wasn't on the list so I fixed that...
    Here is an LZX version :)

    Laszlo Systems INC

    You'll have to be patient for the XAML (Longhorn) or Macromedia Flex versions since they're a ways off ;)

    --
    As seen on Wired: Get a free desktop PC
  50. Re:Teh BUTTSECHS by Anonymous Coward · · Score: 0

    Austria has only a tiny section in Spartacus (the gay travel guide). The biggest section there is for London (over 100 pubs/clubs). But Vienna does have some good pubs and nice food.

  51. this isn't exponential... by Kunta+Kinte · · Score: 1
    It's an exponential-time function (big O of N^2).

    Either this is quadratic time not exponential, or else I'm bigger trouble with this "Analysis of algos." exam I have tommorrow :)

    O(2^N) is exponential.

    --
    Based on upvotes, Ageism is the only "-ism" Slashdotters care about and think isn't SJW
    1. Re:this isn't exponential... by chefren · · Score: 1

      You'll pass that exam just fine. O(N^2) is polynomial, not exponential. Now for a harder problem: is O(N^(log(2)N)) polynomial or exponential?

  52. The Brainfuck implementation was left off the list by zavyman · · Score: 1

    See the Brainfuck solution here.

    It begins like (lameness filter prevents a longer excerpt, just click the link):

    The first stack frame (0 0 0 0 0 0 0 0)
    is used to abort the recursion
    >>>>>>>>

    These are the parameters for the program
    (1 4 1 0 'a 'b 'c 3)
    +>++++>+>>
    >>>>++++++++[-]+>+>-]++>+++>+++>

    And so on.

  53. ..and the answer is.. by chefren · · Score: 1

    It's neither. n^log(2)n grows faster than any polynomial, but more slowly than 2^cn for any c>0.

  54. Please don't add a 109th! by Anonymous Coward · · Score: 0

    An interesting coincidence (?) is that 108 is a special number for Hinduism, Yoga, and other traditions from Indian roots (and other ancient cultures too). The number itself is related to some astronomical relations (http://www.yrec.org/108.html) that Hindus (quite amazingly) should have known before ~4000BC. The author says (in other page) he was "born a Hindu" and although non-religious, likes to explore Hinduism, so he's most certainly aware of this stuff. I wonder if implementing 108 Hanoi programs produces similar effects to, say, vocalizing "OM" 108 times ;-)

  55. Re:Haskell? Obligatory Simpsons Quote by EvilLile · · Score: 1
    Homer(Max): There's three ways to do things; the right way, the wrong way, and the Max Power way!

    Bart: Isn't that the wrong way?

    Homer(Max): Yeah, but faster!

  56. Not really non-recursive. by darkonc · · Score: 1

    His solution isn't really non-recursive.. I actually replied to this point in another comment (that I thought was a reply to this) which includes a more honestly non-recursive solution (and a pointer to an implentation of it even).

    --
    Sometimes boldness is in fashion. Sometimes only the brave will be bold.
  57. Re:Die nerds die! by Zeriel · · Score: 1

    To quote:

    "Lemme guess, you're going to come over to beat me up, but you can't read the road signs to find the way to my house."

    Seriously, I don't care how tough you are--do you realize the percentage of geeks who are angry firearms owners? =P

    --
    "America has done some terrible things. But I know that Americans don't cheer when innocents die." -Dave Barry
  58. Star Wars: Knights of the Old Republic.. by thdexter · · Score: 1

    had a Towers of Hanoi problem in it, with three towers. My non-math-inclined XBOX owning friend invited me over to do it for him. After doing that for him and doing it myself on the game a couple of times, it's 1 min... pretty neat, though.

    --
    I'm on a road shaped like a figure eight; I'm going nowhere but I'm guaranteed to be late.
  59. Re:Die nerds die! by Anonymous Coward · · Score: 0

    YHBT

  60. Re:what if he had spent his time on something usef by minusnone · · Score: 1

    And to those of us who are able to socialize coherently? What would we be called?

    --
    >_
  61. cpp by mr_klaw · · Score: 3, Interesting

    The best one still have to be the version implemented in the C preprocesser.

    http://www0.us.ioccc.org/years.html#1995_vanschnit z

  62. Re:Die nerds die! by Zeriel · · Score: 1

    But I was meta-trolling, so YBHT as well. =P

    Sucka.

    --
    "America has done some terrible things. But I know that Americans don't cheer when innocents die." -Dave Barry
  63. Re:what if he had spent his time on something usef by Anonymous Coward · · Score: 0

    If we banded our collective talents together we could produce things much more useful than Hanio ICMP servers and blue LED case mods. Such as world peace or cost-effective nuclear fission.

    After all, geeks are more intelligent than other people. Our failing is our inability to socialise coherently.


    That was a Simpson's episode and I think the show demonstrated that such a plan will fail horribly ;)

  64. What?!? by Anonymous Coward · · Score: 0

    No solution in Emacs?

  65. Re:what if he had spent his time on something usef by princewally · · Score: 1

    Not geeks?

    --

    -
    "Vengeance is fine," sayeth the Lord.
  66. Re:what if he had spent his time on something usef by minusnone · · Score: 1

    Nah...what if you were social with only geeks? That would still make you a geek. Or would all of those geeks be negated to not being a geek? To geek or not to geek, that is the question.

    --
    >_
  67. I think he does have a life by Anonymous Coward · · Score: 0

    Actually, he does seem to have a life, and he does seem to have done a lot of interesting and useful programming. Read some of the other stuff on the website.

  68. Well, you know waht they say... by David+Gould · · Score: 3, Funny


    I wanted to ask "why"

    Never ask a geek "why". Just nod slowly as you back away.

    --
    David Gould
    main(i){putchar(340056100>>(i-1)*5&31|!!(i<6)<< 6)&&main(++i);}
  69. Holy Crap! Did anybody see the rest of the site? by Anonymous Coward · · Score: 1, Interesting
    So yeah fine towers of hanoi in 108 ways is cool, but i looked around the guy's site, and it seems hanoi is not the only cool thing he does. Check these out -

    The operating systems the guy uses ...

    The operating systems he runs on his apple notebook ...

    The guy's projects - particularly the Sun Solaris Virutalization ...

    The art stuff... the comic etc. ... WOW! Somebody *does* have a lot of time, not to say talent!!!

  70. With Lego by Anonymous Coward · · Score: 0

    http://jpbrown.i8.com/hanoisolver.html

  71. Re:KOTOR by Lord+Bitman · · Score: 1

    Hey look, one of the moderators never played KOTOR and decided they are a valid judge of a post regaurding it! Fucking morons.
    Here is a hint: If you are not familiar with the subject being discussed, do not decide that it is off-topic.

    --
    -- 'The' Lord and Master Bitman On High, Master Of All
  72. vi macro hanoi by Anonymous Coward · · Score: 0

    This guy missed an old one. google in 1991 groups
    for Greg McFarlane hanoi vi macros for the
    source.

    Now there was someone with too much time on
    his hands.

  73. A Useful Tool in Religious Disputation by aebrain · · Score: 2, Interesting

    Everyone agrees that arguments about Languages are Religious, right?

    Well, maybe not. Just have a look at these samplings of code. Now you can argue that some implementations are un-neccessarily complex, and others inefficient. Fair enough. But apart from such deliberately obfuscated grotesques such as the sed implementation, you can get a "within an order of magnitude" estimate of how simple/powerful/readable a language is by looking at the sources.

    For example, contrast the PERL implementation with the C implementation.
    Now look at the Java vs the Ada implementations.
    The similarities, and differences, are instructional.

    Parenthetically, with the forthcoming release of Java 1.5, which has Ada facilities such as strong typing of enumerations and generics, the architectural similarities between Ada and Java will become even more pronounced. IMHO Java has a far neater notation of Object-Oriented features than Ada-95's, but in all other respects suffers from C's over-terse syntax. But that's just my opinion. Look at the examples and form your own.
    What is not a matter of opinion is that readability helps improve code quality. And wonder why "everyone knows" Ada is over-complicated, too difficult to implement, and too costly - especially when open-source free compilers have been around for nearly a decade now.

    --
    Zoe Brain - Rocket Scientist
  74. towers implemented as a Slashdot thread by Anonymous Coward · · Score: 2, Funny

    ``=I=`` I I
    `==I==` I I
    ===I=== I I

    Your move.

    (You wouldn't believe how long it took to get this to display correctly and get past the lameness filter)

  75. Hanoi Mania FAQ by Anonymous Coward · · Score: 0

    It seems the author of the page has put up a faq since he was slashdotte.d Funny!

  76. Try it without recursion by eggoeater · · Score: 1

    My second year as a CS major, one of my profs offered extra credit for a Hanoi tower solution that didn't use recursion in any way. I solved it, but it was much harder than I thought it was going to be. (I think it was coded in Turbo Pascal 5.5. I bet that wasn't one of the 108 implementations.)
    A friend in the same class actually implemented pictures of of discs moving from one tower to another. He got extra-extra credit.
    Steve

  77. Here's my Oracle PL/SQL implementation by Anonymous Coward · · Score: 0

    create or replace package hanoi
    is

    /* towers of hanoi, PL/SQL implementation, by Mark J. Bobak, 12-08-2003 */

    from_peg constant number := 1;
    to_peg constant number := 3;
    using_peg constant number := 2;

    procedure play(n number);

    end hanoi;
    /
    create or replace package body hanoi
    is

    procedure do_hanoi(n number, from_peg number, to_peg number, using_peg number)
    is
    begin
    if(n > 0) then
    do_hanoi(n-1,from_peg, using_peg, to_peg);
    dbms_output.put_line('move '||from_peg||' --> '||to_peg);
    do_hanoi(n-1, using_peg, to_peg, from_peg);
    end if;
    end;
    procedure play(n number)
    is
    begin
    do_hanoi(n, from_peg, to_peg, using_peg);
    end;
    end;
    /

  78. Yay Maxima by Anonymous Coward · · Score: 0

    Maxima 5.9.0.1cvs http://maxima.sourceforge.net
    Using Lisp CLISP 2.31 (2003-09-01)
    (C1) 2^64-1;
    (D1) 18446744073709551615

  79. An old legend... by Insipid+Trunculance · · Score: 1

    Its said that in a very old temple in the hindu city of benares there is an old preist moving 64 rings.When they finish the world ends.

    Reminds me of the arthur clarke story 'the nine billion names of god'........

    --
    Wanted : A Signature.
  80. What Does This Guy Do In His Spare Time? by coyotedata · · Score: 1

    When we get to MSW QZ we will know who wrote it in 108 Crash Programmer +.

  81. back to school mathematics by ongeboren · · Score: 1

    It's a bih O of 2^N morron

    --
    First I wanted to be a chef. Then I wanted to be Napoleon. My ambitions have continued to grow ever since.