This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
yap-6.3/packages/pyswip/examples/hanoi/hanoi.pl

12 lines
224 B
Perl
Raw Normal View History

2010-06-01 00:33:32 +01:00
% Towers of Hanoi
% Based on: http://en.wikipedia.org/wiki/Prolog
hanoi(N) :- move(N, left, right, center).
move(0, _, _, _) :- !.
move(N, A, B, C) :-
M is N-1,
move(M, A, C, B),
notify([A,B]),
move(M, C, B, A).