%% Towers of Hanoi %% try hanoi(4). hanoi(N) :- move(N,left,middle,right). move(1,A,_,C) :- say(A,C), !. move(N,A,B,C) :- N1 is N-1, move(N1,A,C,B), say(A,C), move(N1,B,A,C). say(A,B) :- nl, print( 'move from '), print(A), print(' to '), print(B).