towers of hanoi problem

# Thread: towers of hanoi problem

1. Junior Member
Join Date
Dec 1969
Posts
4

## towers of hanoi problem

Hi everyone,<BR><BR>I&#039;m working on this towers of hanoi program in ASP, and I have the recursive function for calculating the number of steps needed to move all the discs to the right tower. But, what if you put some discs on different towers - for example: you have 3 discs, 1 is on the left, 1 in the middle and 1 on the right. How many steps would it take to move them all to the right tower ?<BR>I need the function for this, and not only for 3 discs - but for any number of discs. Can someone give me an example ?<BR><BR>This is my recursive solution by the way:<BR><BR>Sub MoveDisc(discs, tower1, tower3, tower2)<BR> If discs &#062; 0 Then<BR> counter = counter + 1<BR> Call MoveDisc(discs - 1, tower1, tower2, tower3)<BR> If strDiscs &#060; 15 Then<BR> Response.Write(tower1 & " ---&#062; " & tower3) & "<BR>"<BR> End If<BR> Call MoveDisc(discs - 1, tower2, tower3, tower1) <BR> End If<BR>End Sub<BR><BR>You would help me greatly with his!! Thanks :D<BR><BR>Tom :)

2. Senior Member
Join Date
Dec 1969
Posts
1,424

## Just a simple observation re: Towers of Hanoi

I didn&#039;t do Comp-Sci but I&#039;ll bet that everyone that&#039;s ever done it has been given the Towers Of Hanoi problem to solve - both recursively *and* iteratively!<BR><BR>Furthermore, I&#039;ll bet that when that pimply-faced college student finally got their Tower of Hanoi algorithm working they published it to the Web for the whole world to see.<BR><BR>Which leads me to my question - are you sure that you&#039;ve sufficiently Google&#039;d this?<BR><BR>Cheers,<BR>- Darren<BR><BR>BTW: I must admit I&#039;ve often wondered about building a Towers Of Hanoi project myself - Good Luck!

3. Junior Member
Join Date
Dec 1969
Posts
4

## RE: Just a simple observation re: Towers of Hanoi

To react on your "google&#039;d"..well I&#039;ve been "googling" yesterday from 9 am until...mmm...3 pm, so if that&#039;s not enough then I don&#039;t know lol ;) So yeah, I&#039;ve been looking practically everywhere to find the solution. I&#039;m really stuck with this question. If you can find me a good example in ASP then I&#039;d be glad to see it!!! Not even sites like Planet Source Code or SourceForge had the solution in VB/ASP. So if you can find a working one, just let me know - I&#039;d appreciate that very much! :D<BR><BR>Tom :)

4. Senior Member
Join Date
Dec 1969
Posts
1,424

## RE: towers of hanoi problem

Sure, I&#039;ll take a look at it sometime in the next 2 or 3 days - unless someone comes good between now and then that is.<BR><BR>Do you have the basic rules written down anywhere?<BR><BR>Cheers,<BR>- Darren

5. Senior Member
Join Date
Dec 1969
Posts
973

## Google has millions of examples

Go to Google...... 10 seconds to type in the URL<BR>type in "asp towers of hanoi" for search... another 10 seconds<BR><BR>BOOM!.... your home work is done.<BR><BR>

6. God
Senior Member
Join Date
Dec 1969
Posts
18,177

## "millions"?

I&#039;m going to try and find out!

7. Senior Member
Join Date
Dec 1969
Posts
973

## Thank GOD is it Friday!!

:0 You have a good weekend!! :)

8. God
Senior Member
Join Date
Dec 1969
Posts
18,177

## I only found "about 2,410".

Results 1 - 10 of about 2,410.<BR><BR>&#060;g&#062;<BR><BR>;-)

9. Senior Member
Join Date
Dec 1969
Posts
2,334

## I didn't think you will

go so far to prove it&#039;s not millions:)

10. Senior Member
Join Date
Dec 1969
Posts
973

## :)

I remember doing the ToH for a course in C programming...... It would be better for them to solve the problem on their own.. The residual learning just by doing it would improve their understanding of ASP..............

#### Posting Permissions

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