Question
In this assignment, you will finish the implementation of an iterative solution to the Towers of Hanoi puzzle. Specifically, you will implement the puzzle initialization
In this assignment, you will finish the implementation of an iterative solution to the Towers of Hanoi puzzle. Specifically, you will implement the puzzle initialization and the move operation utilizing the stacks provided. Do not rename existing functions, nor add any additional functions nor member variables!
REQUIREMENTS
The program will read in a text file with containing a single integer: the number of disks for the puzzle.
The program will output the steps required to solve the puzzle for the specified number of disks.
The program will utilize the Hanoi class.
The program will utilize the std::stack library to complete the move functionality.
The only changes will be to the Hanoi.cpp file and will only be within the constructor and the
MakeMove function.
#include "hanoi.h"
Hanoi::Hanoi(unsigned int n) : m_Disks(n)
{
// TODO: set then initial state for the problem
}
void Hanoi::MakeMove(std::ostream& os, unsigned int peg1, unsigned int peg2)
{
// TODO: move the disks between pegs appropriately
// NOTE: Make sure to call PrintMove for each disk movement!
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started