I have an array with different numbers (integers). The length of that array is not set, so it is different every time I run my program. Then I have two other arrays and I want the program to evaluate all possibilites for the distribution of the first array into the other two arrays. For example:
Array 1: 1,3,5
Now the programm should make the other two arrays for example like this:
Array 2: 1,3
Array 3: 5
Or like this:
Array 2: 1,5
Array 3: 3
Consider the placement of an item as a binary digit, then you see that all binary number with the same number of digits as the number of items represent all possible combinations.
So, for three items you have 8 possible combinations:
You can calculate the number of possible combinations using
1 << theArray.Length.You can get a specific combination (0 to possible-1) using: