%
% Filename: queensym.mzn
% Usage:
% > minizinc -a --soln-sep "" --search-complete-msg "" -D "n=5;" queensym.mzn | awk 'NF' >temp1.txt
% > awk 'BEGIN{print "[\\"}; END{print "[]];"}; {print $0 ",\\"};' temp1.txt >temp2.txt
% > gp -qf lexsort.gp > sol5.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;

constraint alldifferent(x);
constraint alldifferent([x[k] + k | k in 1..n]);
constraint alldifferent([x[k] - k | k in 1..n]);
constraint forall([x[k] + x[n+1-k] == n+1 | k in 1..n div 2]);

solve satisfy;

output [show(x)];