This code does nothing:
P1.PUSH(P1.POP());
it pop a value from the stack and put it back on the stack, it ends with ni change. All this if related code is not bugged.
Basically, the towers of Hanoi don't need a stack structure, just an array with the peg number of each disk.
Nota; the pile can be called a stack, but do not imply using a stack structure.
To start, all disk are on peg 1.
The basic move.
To move a stack from starting peg to destination peg:
- move stack minus largest disk to intermediate peg
- move largest disk to destination peg
- move stack minus largest disk to destination peg