taboch_queens.pl

loading
details
attribute value
description
owner Johannes Waldmann
uploaded 2017-08-17 03:45:08.0
disk size 383 Bytes
downloadable true
type
attribute value
name no_type
processor id 1
description this is the default benchmark type for rejected benchmarks and benchmarks that are not associated with a type.
owning community none
loading contents
%query: queens(i,o).

queens(X,Y) :-
   perm(X,Y),
   safe(Y).

perm([],[]).
perm([X|Y],[V|Res]) :-
  delete(V,[X|Y],Rest),
  perm(Rest,Res).

delete(X,[X|Y],Y).
delete(X,[F|T],[F|R]) :-
  delete(X,T,R).

safe([]).
safe([X|Y]) :-
  noattack(X,Y,1),
  safe(Y).

noattack(X,[],N).
noattack(X,[F|T],N) :-
   X =\= F,
   X =\= F + N,
   F =\= X + N,
   N1 is N + 1,
   noattack(X,T,N1).
popout

content may be truncated. 'popout' for larger text window.

actions get anonymous link download benchmark