%% azpc -p reduceQueen.pl /no /e reduceQueen /lib $(AZ-Prolog)\obj\prolog2.res

top_level:- prompt(_,''),repeat,read_x([AL,BL]),put(AL,BL,L),write(L),nl,fail.

read_x(X):- read(X),!.
read_x(_):- halt.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%

put([],L,L) :- !.
put(S,A,Ans) :- select(S,B,C), safe(B,B,A), put(C,[B|A],Ans).

select([A|L],A,L).
select([A|L],B,[A|R]) :- select(L,B,R).

safe(A,B,[]) :- !.
safe(A,B,[C|D]) :- AA is A+1, AA\==C, BB is B-1, BB\==C, safe(AA,BB,D).
