% % Filename: zerosum.mzn % Usage: % > minizinc -a --soln-sep "" --search-complete-msg "" -D "n=5;" zerosum.mzn | awk 'NF' >temp1.txt % > awk 'BEGIN{print "[\\"}; END{print "[]];"}; {print $0 ",\\"};' temp1.txt >temp2.txt % > gp -qf -s 256000000 lexsort.gp > temp3.txt % > awk -f array.awk -v rows=3 temp3.txt >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); } */ % > cat array.awk /* { size = split($0, a); cols = size/rows; print NR; for(i = 0; i < rows; ++i) { for(j = 0; j < cols-1; ++j) printf("%2d ", a[i*cols+j+1]); printf("%2d\n", a[(i+1)*cols]); } } */ % % see also http://www.minizinc.org, http://pari.math.u-bordeaux.fr % include "globals.mzn"; int: n; int: m = 3; array[1..m, 1..2*n+1] of var -n..n: x; constraint forall([alldifferent([x[i,j] | j in 1..2*n+1]) | i in 1..m]); constraint forall([sum([x[i,j] | i in 1..m]) == 0 | j in 1..2*n+1]); constraint forall([x[1,i] == -n-1+i | i in 1..2*n+1]); solve satisfy; output [show(x)];