What's the best distribution algorithm to use if I want to place numbers 1, 2, and 3 in an array. The array can be variable length and so can the number of occurrences of 1,2,and 3. The array is however grouped into sub groups all of the same size and the number 1 can only appear max once per subgroup, the number three many times, and the number two can only be placed more than once in a subgroup after each subgroup has received one. The issue is that the distance between the last placed number (may be across sub groups, or within sub groups) can not be passed. So if the distance is 10 within a group, we can't go more than 10 array spots without having a number placed, if the distance is across groups than we can't go more than 10 without having a number placed within and across groups. I want to randomize it as well, choosing sub groups and/or position in sub groups at random whether using a linear or circular approach. I guess an approach would be to do shuffling afterward if we did violate the distance restriction, but I'm not sure if that would ruin what we tried to accomplish by placing the numbers in the first place. If anybody has any suggestions or links they can refer me to that would help, math isn't my strong suit. Thanks.