Let\'s say I have 2 groups of numbers:
{1, 2, 3},
{4, 5}
I\'d like to create an algorithm (in Java) that outputs the following 6 combinations:<
How about the following pseudo code (w/o recursion)
// Create the initial result filled with the first set of numbers
List result = new List()
For each number in the first set
result.add(new List(number))
// Iterate over the following sets to permutate over
For each remaining set S
List newResult = new List()
For each list L in result
For each number N in S
newResult.add(copy of L with N added)
result = newResult