Here’s one of those ColdFusion things that seems like it should be so easy… but I’m not finding the easy path.
I have an array of lists.
The array could be any size, and the length of each list can be any size.
(this can be manipulated into a multi-dimensional array, whatever… the point is, i have a list of lists)
For example
-
129,128,127
-
130,131,132
-
135,133,134
-
137,138,136
-
140,139
-
141,142
Or a short version… it can vary
-
13,14,15
-
11,12
What I need is an array, query or some other data structure
containing all the possible unique combinations, taking one from each list in order … so for the short version, there would be 6 unique combinations. For the first longer example, we would have 3*3*3*3*2*2 = 324 unique combinations.
Counting them is easy… but what’s the best way get the actual combinations in a structured format?
Must be missing something simple… I’ve been very close for hours now!
:-/
Here’s my take.
Credit goes to the php function in this post on codingforums.com: http://www.codingforums.com/showpost.php?p=945289&postcount=3
I just figured how to re-write it in cfml.