Interview question on constraint

In reply to burra thanuja:

Can anyone plz help me with this constraint question…
Take a rand variable with array size 10,need to get unique values in each location without using unique keyword and for any of 2 locations we need to get same value?


class unq_arr;
 rand int unsigned d;
 rand int unsigned arr[10];

 constraint arr_c{
   foreach(arr[i]) { arr[i] inside {[1:10]};}
   foreach(arr[i]) { arr.sum() with (int'(item==arr[i])) == (arr[i]==d ? 2:1);}
 }