Question: In this project, we will implement a class that can solve a three - pole Tower of Hanoi puzzle for any number of discs starting
In this project, we will implement a class that can solve a threepole Tower of Hanoi puzzle for any number of discs starting from any source pole and going to any other destination pole. First, our class will do so recursively, and then it will do so recursively and efficiently.
TODO
Implement the Hanoi class in two stages.
Stage :
Implement the recursive solution.
Commit and push your work as you do so committing at a minimum after each function definition.
Test drive your recursive implementation from srcmain cpp confirming correct solutions.
Commit and push your work.
Iterate as necessary, and commit and push your work throughout.
Commit and push successful program runs for stage
Stage :
Memoize and optimize your solution.
Commit and push your work.
Test drive your memoized implementation from srcmain cpp
Commit and push your work.
Run unit tests.
Iterate as necessary, and commit and push your work throughout.
Commit and push successful program runs for stage Solution output will of course be identical to stage
Add a "Project Complete" comment to your Feedback pull request.
Give yourself yet another high five!
Stage
std::string Hanoi: solveint numdiscs, int src int dst int tmp
This is the one and only public member function of the Hanoi class. It represents the user interface.
The user will call solve and provide the number of discs numdiscs they would like to move from the source pole src to the destination pole dst using the third pole as a temporary pole
solve returns a string representation of the necessary moves preceded by the following line:
# Below, A B means 'move the top disc on pole to pole
solve will supply this line and then add to it the string solution provided by calling getmoves
For example, calling solve would ultimately return the string:
# Below, A B means 'move the top disc on pole to pole
std: :string Hanoi: :getmovesint numdiscs, int src int dst int tmp
getmoves returns the string representation of the required moves to move numdiscs discs from the src pole to the dst pole using the tmp pole as a temporary pole.
Each move will be on its own line.
For example, getmoves would return the string:
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
