
public class Hanoi {

	
	public static void towersOfHanoi(int N, int from, int to, int spare,int indent){
		if (N == 1) {
			moveOne(from, to, indent);
		}
		else {
			towersOfHanoi(N-1, from, spare, to, indent+2);
			moveOne(from, to, indent+2);
			towersOfHanoi(N-1, spare, to, from, indent+2);
		}
	}
	
	private static void moveOne(int from, int to, int indent){
		System.out.format("%"+(indent+8) + "s\n", from + " ---> " + to);
	}
	public static void main(String[] args) {
		Hanoi.towersOfHanoi(4, 1, 3, 2, 0);

	}

}
