import java.util.Scanner;

/**
 * Demonstration of a solution to the classic Tower of Hanoi problem
 * @author Hyrum D. Carroll
 * @version 0.2 (May 4, 2020)
 */
public class TowerOfHanoi02{
    public static void moveDisc( String from, String to){
        System.out.println("Moving from " + from + " + to " + to);
    }

    public static void solve(int n,
                             String startingTower,
                             String tempTower,
                             String targetTower){
        System.err.println("solve("+n+", " + startingTower + ", "+tempTower+", "+targetTower+")");

        if(n == 0){
            return;
        }

        // move all but the last disc from the first to the middle
        solve(n-1, startingTower, targetTower, tempTower);

        // move largest disc to end
        moveDisc(startingTower, targetTower);

        // move all but the last disc from the middle to the right
        solve(n-1, tempTower, startingTower, targetTower);
    }

    public static void main( String[] args ){
        Scanner stdinScanner = new Scanner( System.in );
        int numDiscs = 0; // number of discs

        System.out.print( "Please enter the number of discs: " );
        numDiscs = stdinScanner.nextInt();
        String startingTower = "tower 1";
        String spareTower = "tower 2";
        String endingTower = "tower 3";

        solve( numDiscs, startingTower, spareTower, endingTower);
    }
}