# Thread: Distribution of #'s across an array of sub groups

1. ## Distribution of #'s across an array of sub groups

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.

2. Show some code and we will help.

3. That's the problem, I don't know how to code a solution since I have no idea how to approach it. I don't actually need a solution just a starting point maybe, like an idea of how to approach it. Or some links to look at that will point me in the right direction. Than I can code something for debate.

4. Allow me to assist:

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.
There are enough keywords in your post to almost write an entire program without the actual algorithm being put into place. You should at least, from your post, understand the data structure that you will need and how you will need to design the system to support the given requirements.

Sorry, I don't buy that you don't know where to start. Think about it, do some bit of design in UML or something, and then post what you come up with. Post the UML if you want to but post something. You have been given very clear requirements (be thankful) with which to start designing with. I'd help more but it's the weekend and I'm most assuredly not at work nor getting paid for this.