C++

All details will be provided after selecting tutor The goal is to move all disks

Photo of author

By admin

All details will be provided after selecting tutor
The goal is to move all disks from the first peg (left) to the very last peg (right).
You can assume at the begining all disks are stacked at the first peg. Also the disks are diametrically sorted with the largest disk at the bottom and the smallest disk at top of peg.
Disks should be named using numbers, 1 is the smallest disk, ‘n’ is the largest disk. Pegs should be named using letters – the first peg ‘A’, then the second peg ‘B’ and so on. For 4 peg version of the problem, it involves moving all n disks from peg A to peg D using pegs C and B as intermediary pegs. For 5 peg version of the problem, it involves moving all n disks from peg A to peg E using pegs B, C and D as intermediary pegs.
The solution needs to be recursive and supports any number of disks.
The program takes 3 arguments. Number of Pegs, Number of Disks and Output File Name.
For example, the following command asks for the solution of puzzle with 3 pegs, 4 disks, and the file will be written to 3_4.txt
Output
Each line of the output file will be a single move of a single disk, with the format of [DISK] [FROM] [TO]. So disk 1 moved from peg A to peg B will be 1 A B.
Below is the solution of 3 pegs and 3 disks, moving from peg A to peg C.
1 A C
2 A B
1 C B
3 A C
1 B A
2 B C
1 A C