Say I have [10, 100], n = 3. (e.g. like we have 3 digits for a number) I need to generate all possibles in javascript.
I think the output will be
[
[10, 10, 10],
[10, 10, 100],
[10, 100, 10],
.......
]
Say I have [10, 100], n = 3. (e.g. like we have 3 digits for a number) I need to generate all possibles in javascript.
I think the output will be
[
[10, 10, 10],
[10, 10, 100],
[10, 100, 10],
.......
]
Permutations with repetition using recursion - JavaScript
I should do more search....
var abc = function () {
var holdingArr = [];
var threeOptions = ["a", "b", "c"];
var recursiveABC = function(singleSolution) {
if (singleSolution.length > 2) {
holdingArr.push(singleSolution);
return;
}
for (var i=0; i < threeOptions.length; i++) {
recursiveABC(singleSolution.concat([threeOptions[i]]));
}
};
recursiveABC([]);
return holdingArr;
};