The Mother Of All C Problems
Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: The Mother Of All C Problems

  1. #1
    Senior Member PacketThirst's Avatar
    Join Date
    Aug 2004
    Posts
    258

    Thumbs up Another C challenge

    Greetings All !

    Want to know what Towers Of Hanoi Problem is ??

    Check Out this awesome site
    http://www.superkids.com/aweb/tools/logic/towers/

    Last year i had to write a program in C which solves the Towers Of Hanoi Problem Using Recursion as a part of my assignment. I tried my best to find a logic. I could manage to visualize solving the problem with 4 disks.I got a headache trying to find the logic !!.This code is available all over the net.But copying that wouldn't make my intellectual conscience happy.I know there that there are a lot of talented people out there in AO.Code this problem and explain the working ... if u can

  2. #2
    Member
    Join Date
    Aug 2004
    Posts
    51
    arrrgh! so hard to find the real solution for it, I only have one move left and f@##$ck! I couldnt do it!
    juicy`peanut

  3. #3
    Just a Virtualized Geek MrLinus's Avatar
    Join Date
    Sep 2001
    Location
    Redondo Beach, CA
    Posts
    7,324
    Hehe... takes some patience and moving them pieces around. I got it on 7 disks. Took me about 20 minutes. That said, I don't think I could necessarily explain how I did it... (although I will note that I didn't use "Solve the Puzzle" button).
    Goodbye, Mittens (1992-2008). My pillow will be cold without your purring beside my head
    Extra! Extra! Get your FREE copy of Insight Newsletter||MsMittens' HomePage

  4. #4
    Senior Member PacketThirst's Avatar
    Join Date
    Aug 2004
    Posts
    258
    Believe it or not ! .. There's actually a program in C which solves this problem using recursion.

    Coding this is considered to be super elite !!

  5. #5
    well, it isn't really that hard... as you see in the link you gave us, there is a "solve" button, so this means that they already coded it. however, i do not have the time (and interests) to solve this problem, cause although it isn't that hard, it will take a lot of time

  6. #6
    Developer Extraordinar
    Join Date
    Jul 2002
    Location
    Internets
    Posts
    571
    I solved it, I don't know how long it took me, probably somewheres between 15 and 25 minutes, it wasn't that hard to do, although it is indeed hard to explain how to do it. Basicly I moved two at a time, well, not at a time, but I mored a little one to one spot, and a bigger one to another, I placed the littler one on the bigger one, and replaced an even larger one on the open tower. Then I moved the smallest to the biggest tower, and moved one that was one step lower on top of the one that is one step bigger, the replaced the smallest on the tower of two (making it a tower of three) that I had made. I basicly did that for all of them, there was probably more to it, but I'm sure you get the general idea how I myself solved it.

    microburn
    Come to UnError.com

  7. #7
    Senior Member PacketThirst's Avatar
    Join Date
    Aug 2004
    Posts
    258

    Angry

    Microburn... do u think its possible for you to make this work using recursion ? ..

    Its this "recursion" thing that really screws my head up !!

  8. #8
    Elite Hacker
    Join Date
    Mar 2003
    Posts
    1,407
    I may be able to do it in java. I solved it by hand, but sheesh, how would you even know? You almost have to do it in gui just to track it. I think that might be beyond me to come up with a pattern to solve it. I guess maybe the key is to start small and make your way up. I may give it a shot .

  9. #9
    22 lines with recursion using c++, not to difficult if you think about it

  10. #10
    Senior Member
    Join Date
    Oct 2001
    Posts
    786
    You don't need a GUI to keep track of it. Instead, assign a "weight" to each block. That is the way the computer "sees" it.


    The way to do this is to build multiple mini-towers. Pretty much what Microburn said. I think I'll take this challenge on after I play the game a bit more...


    Edit: I can solve 7 in under 14 minutes while making mistakes, talking on MSN, and eating... I've come to notice some sort of even/odd pattern, but I haven't manged to form any definate rules to when it works or not...

    Edit: Down to 10 minutes and I have found some sort of pattern... more playing before I get to coding...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •