I was trying to solve this problem in Minizinc, taken from Puzzle taken from Gardner :
Ten cells numbered 0,...,9 inscribe a 10-digit number such that each cell, say i, indicates the total number of occurrences of the digit i in this number. Find this number. The answer is 6210001000.
I solved it, and the code is working fine with Gecode:
int: n=9;
set of int: N=0..n;
array[N] of var N: cell;
include "globals.mzn";
constraint global_cardinality(cell, N, cell);
solve satisfy;
output [show(cell), "\n", show(index_set(cell)), " -- ", show(index_set(N))];
Output from Gecode:
[6, 2, 1, 0, 0, 0, 1, 0, 0, 0]
0..9 -- 1..10
----------
==========
However, G12 solvers complain about a assertion failed in global_cardinality:
in call 'assert' Assertion failed: global_cardinality: cover and counts must have identical index sets
True, as the output from Gecode shows, N is 1..10 and cell is 0..9. So my questions are:
- Why Gecode is working? Different implementation or my program is buggy but I was lucky?
- How can I fix the program to work with G12 or to make it robust/correct?