I have a problem similar to someone elses - however, its slightly different and I could use some help.
I have two arrays:
var array1=["A","B","C"];
var array2=["1","2"];
Please note they can be of different sizes. How can I produce another array to contain every UNIQUE set of the combined arrays above, so that the elements of each array do not repeat for the set as follows?
var combos=[
["A1","B2"],
["A1","C2"],
["B1","C2"],
["A2","B1"],
["A2","C1"],
["B2","C1"]
]
note: ["C1","A2"] (and similar) is a repeat and would not be included in the set.
furthermore -> if array2=["1","2","3"]
then
var combos=[
[A1, B2, C3],
[A1, B3, C2],
[A2, B1, C3],
[A2, B3, C1],
[A3, B1, C2],
[A3, B2, C1]
]
I believe this is a form of permutation, but I need help in how to implement the set merge in node.js. Thanks in advance!