I am trying to solve a constraint where an array A (say int) has a certain configurable length and its contents are repeated 'k' times each except for 1 element that is unique to the array.
Example: A (say length 10 and k = 3) = {4, 4, 4, 7, 7, 7, 10, 10, 10, 30}
Each value is repeated k times and 30 is unique to the array.
I have been able to solve it in this way:
Given size of the array and k, I generate a value of unique number of elements required. This is pseudo code and I paraphrase but you get the idea.
rand int uniq_e = (A.size()/k) + 1;
rand int uniq_A of size uniq_e.
unique {uniq_A}
Then in post randomize, just replicate all but 1 element k times and create array A.
However, is there a better way to solve this using constraint blocks directly. (tried A.xor and A.sum together but does not seem to work)