In reply to myselfprakhar:
Anyone can see that unique word in your first post example or topic ???
let me know, I will hire this guy.
back to the question: i.g. sub_group has 4 unique items
value: proper size (4,8,12…) with proper item occurrence (4*N)
temp: the order you can’t generate, unique each subgroup
Don’t you think to have valid temp first, then use shuffle() to have value?
How you guarantee your value has valid content? from constraint?
From my experience, temp value should be generated at the same place.
Anyway if you give me value with proper content, then I have no idea about how unique subgroup size is.
Here you go:
// given valid value[] and calculating temp[]
int tbl[int];
int q[$];
int temp[] = new[value.size];
foreach (value[i]) begin
if (!tbl.exists(value[i]))
tbl[value[i]] = 1;
else
tbl[value[i]]++;
end
q = tbl.find_index() with(1);
for (int i = 0; i < value.size; i+=q.size) begin
if (i % q.size == 0) begin
q.shuffle();
for (int j = 0; j < q.size; j++)
temp[i + j] = q[j];
end
end