%
% Filename: queenrot.mzn
% Usage:
% > minizinc -a --soln-sep "" --search-complete-msg "" -D "n=20;" queenrot.mzn | awk 'NF' >temp1.txt
% > awk 'BEGIN{print "[\\"}; END{print "[]];"}; {print $0 ",\\"};' temp1.txt >temp2.txt
% > gp -qf -s 256000000 lexsort.gp > sol20.txt
% > cat lexsort.gp
/*
{
a = read("temp2.txt"); b = vecsort(a, lex);
for (i=1, #b, my(len = #b[i]); if (!len, next());
  for(j=1, len-1, print1(b[i][j], " ")); print(b[i][len]));
quit(0);
}
*/
%
% see also http://www.minizinc.org
%

include "globals.mzn";
int: n;
array[1..n] of var 1..n: x;
array[1..n] of var 1..n: y;

constraint inverse(x,y);
constraint alldifferent([x[k] + k | k in 1..n]);
constraint alldifferent([x[k] - k | k in 1..n]);
constraint forall([x[k] + y[k] == n+1 | k in 1..n]);

solve satisfy;

output [show(x)];