fork download
  1. :- set_prolog_flag(verbose,silent).
  2. :- prompt(_, '').
  3. :- use_module(library(readutil)).
  4.  
  5. search([]):-!.
  6. search([X/Y|XYs]):-member(Y,[1,2,3,4,5,6,7,8]),
  7. search(XYs),
  8. not(attacks(X/Y,XYs)).
  9.  
  10. attacks(X/Y,XYs):-
  11. member(X2/Y2,XYs),
  12. (Y is Y2;
  13. Y is Y2+X-X2;
  14. Y is Y2-X+X2).
  15.  
  16.  
  17. main:-
  18. process,
  19.  
  20. process:-
  21. /* your code goes here */
  22. XYs=[1/Y1,2/Y2,3/Y3,4/Y4,5/Y5,6/Y6,7/Y7,8/Y8],
  23. search(XYs),
  24. write(XYs),
  25.  
  26. :- main.
Success #stdin #stdout #stderr 2.79s 6976KB
stdin
Standard input is empty
stdout
[1/1,2/5,3/8,4/6,5/3,6/7,7/2,8/4]
stderr
Warning: /home/9aVHjn/prog:21:
	Singleton variables: [Y1,Y2,Y3,Y4,Y5,Y6,Y7,Y8]