7
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:
[]
Related: Helping the farmer
– Peter Taylor – 2014-06-23T21:44:37.3201Some explanation of what do you mean with 'overlap array'? Or a link... – edc65 – 2014-06-23T23:31:16.393
@edc65 I've removed the term from the question to avoid confusion. They're just arrays. – nderscore – 2014-06-24T01:23:11.227
@edc65, it's exact set cover with some of the input implicit. So the input sets are the elements to cover, and for each element of their union there is a set consisting of those input sets which contain that element. – Peter Taylor – 2014-06-24T07:39:33.123