The goal is to write a function or program which takes a set of integer arrays and returns a set of all possible arrays which meet the following criteria:
- A valid array must contain at least one number from each of the input arrays.
- A valid array cannot contain more than one number from a single input array.
- A valid array cannot contain duplicate values.
Additional rules:
- Order of the output does not matter.
- Input/Output can be in any format you wish.
- If no valid arrays exist, the result should be an empty array or blank string.
Examples:
input:
[[1,2],
[2,1,0],
[0,3,1]]
output:
[[2,3],
[1]]
input:
[[1,3,4,7],
[1,2,5,6],
[3,4,8],
[8,9]]
output:
[[6,7,8],
[5,7,8],
[2,7,8],
[4,6,9],
[4,5,9],
[2,4,9],
[3,6,9],
[3,5,9],
[2,3,9],
[1,8]]
input:
[[1,2,3],
[2,3,4],
[1,4]]
output:
[]