// hanoi.cpp  -- Play the Hanoi towers game

#include <iostream>

// We write a function that prints out the moves required
// to play the Hanoi Towers game with three pegs, fromPeg
// on which we have n disks (from top to bottom in increasing)
// sizes), toPeg where we want to move 
// the pegs, and extraPeg, the peg we can use so as not 
// to violate the rule that at no time a larger peg cannot 
// be on a smaller peg. In a move we can transport from 
// one peg to another only a single disk.
void hanoi(int n, char fromPeg, char toPeg, char extraPeg)
{
	if (n > 0)
	{
		hanoi(n-1, fromPeg, extraPeg, toPeg);
		cout << "Moving from peg " << fromPeg << " to peg " << toPeg << endl;
		hanoi(n-1, extraPeg, toPeg, fromPeg);
	}
}

// CAN YOU ESTIMATE HOW MANY LINES WILL BE PRINTED OUT BY
// THE FUNCTION hanoi AS A FUNCTION OF n?

void main(void)
{
	int hmny;
	cout << "Playing the Hanoi Towers Game" << endl;
	cout << "Enter how many disks you want to use: ";
	cin >> hmny;
	hanoi(hmny, 'A', 'B', 'C');
}
