I have an NSMutable array of N elements. Each element is also an NSMutable array of k NSNumbers. In other words a table with variable length columns.
I need to generate a new array containing all the possible ways of selecting one element per column.
Example:
1 1 1 1 1 1
2 2
Result:
1 1 1 1 1 1
2 1 1 1 1 1
1 1 1 1 1 2
2 1 1 1 1 2
The following method will iterate through the possible column indices that you want to take, beginning with
[0,0,...,0]:To use it, do something along these lines:
Note that I did not test or debug this code, it’s just to give you an idea of what to do.