How to, Sequentially distribute data from a list to arrays (or some other structure) of fixed size/weight.
For example, lets say I have a list of 10 elements. I want to sequentially distribute the elements to 3 arrays A, B, and C. The arrays are given a weight lets say A=3, B=5, and C=2.
The element would be distributed in the following fashion.
A - list[0] list[3] list[6]
B - list[1] list[4] list[7] list[8] list[9]
C - list[2] list[5]
If the size of the list was 13, then after the above distribution, it would start again after the cycle completes
A - list[0] list[3] list[6] list[10]
B - list[1] list[4] list[7] list[8] list[9] list[11]
C - list[2] list[5] list[12]
The size of the list is dynamic, so in the above example, the list size would be 3, 4, or 100, etc. And the number of arrays (or structure) and weight of the arrays are available in runtime only.
Is there a good way to solve it?