How to generate a pattern 110011001100 using constraint

In reply to big123:

In reply to disturbedWolf:
Thanks for the solution .
Can you please enlighten me the approach towards it .It will be really helpfull

My approach is what we call “hardcoded”. I am assuming that the pattern that you need to generate is given, and if it needs to be changed, you ll create a new class and override the constraint with the new one.

Now, for the code that you have, I dont understand why you need both “a” and the “pattern” queue both. You should just be able to use a single queue/array and randomize.

As for the constraints in my example, size_arr_C will limit the size of the dynamic array bit_pattern. Then, pattern_C will be used to get the desired pattern, i.e for a byte, 1100, so mod 0,1 will give you 1 and another 1, and then %2,3 will be set to 0.
Rest of the code is just infrastructure and presentation.

You can also randomize just the size of the pattern, and put the “known pattern” in post_randomize. Just have a rand var which will determine the size and then new your pattern in post_randomize.