Reputation: 1123
I have these sets of numbers
[1, 2] [1,2,3] [1,2]
I need an javascript algorithm that can calculate the possible combinations of these sets or any number of sets. So the number of possible combinations is 2 x 3 x 2 = 12.
The possible combinations are:
1, 1, 1
1, 1, 2
1, 2, 1
1, 2, 2
1, 3, 1
1, 3, 2
2, 1, 1
2, 1, 2
2, 2, 1
2, 2, 2
2, 3, 1
2, 3, 2
Is there some npm library that can do this calculation or this requires a custom algorithm?
Upvotes: 0
Views: 230
Reputation: 347
You have a js-combinatorics
check https://www.npmjs.com/package/js-combinatorics
Upvotes: 2