-2

Given n arrays of random sizes, I need to permute them like this:

[a1, a2, a3]
[b1, b2]
[c1, c2]

[a1, b1, c1]
[a1, b1, c2]
[a1, b2, c1]
[a1, b2, c2]
[a2, b1, c1]
[a2, b1, c2]
[a2, b2, c1]
[a2, b2, c2]
[a3, b1, c1]
[a3, b1, c2]
[a3, b2, c1]
[a3, b2, c2]

The columns order matters, lines dont.

What is good way to achieve this. If possible, using this method contract:

<T> List<List<T>> permute(List<T>... lists)
Michael Pacheco
  • 948
  • 1
  • 17
  • 25

1 Answers1

0

What you're searching for is a combination, not a permutation. May have a look at this: Generate all combinations from multiple lists

Tobias
  • 2,547
  • 3
  • 14
  • 29