G
Guest
I have a collection of groups: Group1, Group2, ...
In each group there are a number of items.
I need to produce a list of all possible item combinations where one item is
picked from each group.
What would be the best algorithm for this? Recursive or iterative?
What would be the best datatypes to use?
Readability is more important than speed.
Example:
Group1: Item1, Item2
Group2: Item3, Item4, Item5
Group3: Item6, Item7
This would produce the following list:
Item1, Item3, Item6
Item1, Item3, Item7
Item1, Item4, Item6
Item1, Item4, Item7
Item1, Item5, Item6
Item1, Item5, Item7
Item2, Item3, Item6
Item2, Item3, Item7
Item2, Item4, Item6
Item2, Item4, Item7
Item2, Item5, Item6
Item2, Item5, Item7
In each group there are a number of items.
I need to produce a list of all possible item combinations where one item is
picked from each group.
What would be the best algorithm for this? Recursive or iterative?
What would be the best datatypes to use?
Readability is more important than speed.
Example:
Group1: Item1, Item2
Group2: Item3, Item4, Item5
Group3: Item6, Item7
This would produce the following list:
Item1, Item3, Item6
Item1, Item3, Item7
Item1, Item4, Item6
Item1, Item4, Item7
Item1, Item5, Item6
Item1, Item5, Item7
Item2, Item3, Item6
Item2, Item3, Item7
Item2, Item4, Item6
Item2, Item4, Item7
Item2, Item5, Item6
Item2, Item5, Item7