This commit was generated by cvs2svn to compensate for changes in r4,
which included commits to RCS files with non-trunk default branches. git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@5 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
16
CHR/chr/examples/examples-queens.domain
Normal file
16
CHR/chr/examples/examples-queens.domain
Normal file
@@ -0,0 +1,16 @@
|
||||
% n-queens with finite domains
|
||||
|
||||
:- setval(domain,number).
|
||||
|
||||
queen(N,L):-
|
||||
length(L,N),
|
||||
L::1..N,
|
||||
queen(L).
|
||||
|
||||
queen([]).
|
||||
queen([X|Xs]):- safe(X,Xs,1),queen(Xs).
|
||||
|
||||
safe(X,[],N).
|
||||
safe(X,[H|T],N):- no_attack(X,H,N), M is N+1, safe(X,T,M).
|
||||
|
||||
no_attack(X,Y,N):- X ne Y, X ne Y-N, X ne Y+N, Y ne X-N, Y ne X+N.
|
Reference in New Issue
Block a user