January 19th, 2009, 08:57 AM
Algorithm all possible combination multiple values
I am looking for an algorithm for generating all possible combinations of an array which has multiple possible values at every index. Example:
array = [[0,1,2],[0,1],[0,1,2,3],[0,1]]
So the order of the original array values should be preserved, I only need the possible different combinations of the inner arrays (i.e. the possible values). I have a solution, but it's rather complicated and consists of several loops. So, I would like to know if there is a better way to do this. Some pseudo code would be appreciated. Thanks!
January 19th, 2009, 12:04 PM
Re: Algorithm all possible combination multiple values
Never mind, I have solved it myself. The solution is to use an recursive algorithm that takes an multidim array as an argument as well as the row count.
Click Here to Expand Forum to Full Width
This is a CodeGuru survey question.