2D array constraint randomization

In reply to jyothsna04:

The code you wrote and the code in the marked solution is illegal. The reduction methods only iterate over a single dimension of an array

  constraint c2 {
 
      foreach (a[i]) {
        a[i].sum() with (int'(item)) == 10;         // rows a[i][0] + a[i][1] 
        a.sum() with (int'(a[item.index][i]))== 10; // cols a[0][i] + a[1][i] 
    }
   //   unique{a};  // array size and sum too small to make unique
  }
3 Likes