Hardware interview practice
Constrain one triplicate and seven singletons
Randomize ten integers in 0..31 so one selected value occurs exactly three times and every other value occurs once.
Starting point
Question code
rand int unsigned arr[10];
rand int unsigned repeated;Reviewed example
Work through one case
Input
repeated=4, arr='{4,9,4,1,6,11,4,2,8,10}Expected output
Legal randomization resultFour appears exactly three times and all seven remaining values are unique.
What to cover
Requirements
- Restrict all values and repeated to 0..31.
- Make exactly three positions equal repeated.
- Make the other seven values pairwise distinct and different from repeated.
- Allow the three repeated positions to appear anywhere.
