Tower of Hanoi

I am trying to solve the Tower of Hanoi problem. I broke the problem into two parts. The movement of a particular disk and then that particular disks's movement with respect to the towers themselves. So right now, I am trying to figure out how to program which disks moves. The pattern that I found was

2 disks
121
3 disks
1213121
4 disks
121312141213121
5 disks
1213121412131215121312141213

so on and so forth.

And I am trying to program this recursively. And it is very difficult. Any suggestions to help me out here? Thank you!

Also, is this a beginner problem? Because this seems like a pretty difficult problem for a beginner... just my opinion...

Yeah this isn't C++ at all also you showed no code. Which none of us will understand try posting this in General C++ maybe you will get some help. Good Luck
Yeah this isn't C++ at all also you showed no code. Which none of us will understand try posting this in General C++ maybe you will get some help. Good Luck
I lol'd...
What's there not to understand?

Developing software is basically the process of having a problem and defining the problem so that it is easy to solve/implement.

Also, is this a beginner problem? Because this seems like a pretty difficult problem for a beginner... just my opinion...

one part, writing a recursive function, is a beginner problem the other one, writing the algorithm, is a little bit more advanced but not impossible for a beginner.

Try finding a pattern, for example:
"When there is an even number the first disc has to be put on stack 2, otherwise on stack 3.
Afterwards just place the discs on 2 and 3 so that you get the whole stack on stack 2.
Then place the biggest disc on pile 3 and so on..."

The hard part here is making a recursive function out of the algorithm or writing the algorithm so that you can use it as recursive function

And I am trying to program this recursively. And it is very difficult. Any suggestions to help me out here? Thank you!

recursive is a good idea, stick with it ...


I'll come back when you started coding .
Last edited on
@Blackhart98

I apologize for anything that I posted that doesn't comply with this forum. Sorry! I'll try to be more specific in my questions next time.

@Gamer2015

Okay. I will try it again. Like you said, I think I need to find the pattern (which you hinted at), then the write the algorithm, and then try to code it. Thank you!
Last edited on
Topic archived. No new replies allowed.