Wednesday, May 4, 2011

TOWER OF HANOI PROLOG IMPLEMENTATION



towerofhanoi(1,X,Y,_):-  write(' move the disk from'),write(X),write('TO') ,write(Y),nl.


towerofhanoi(N,X,Y,Z):- N >1, M is N-1, towerofhanoi(M , X, Z,Y),                                          towerofhanoi(1,X,Y,_),towerofhanoi(M,Z,Y,X).

No comments:

Post a Comment