% hanoi(N,X,Y,Z).
% Prints out the moves for moving N discs from X to Y using Z

hanoi(1,X,Y,_) :-
   write('move from '), write(X), write(' to '), write(Y), nl.
hanoi(N,X,Y,Z) :-
   N>1,
   N1 is N-1,
   hanoi(N1,X,Z,Y),
   write('move from '), write(X), write(' to '), write(Y), nl,
   hanoi(N1,Z,Y,X).
