Answers for "permutaciones con repeticion javascript"

0

permutaciones con repeticion javascript

function permutator (input) {
  var set =[];
  function permute (arr, data) {
    var cur, memo = data || [];

    for (var i = 0; i < arr.length; i++) {
       cur = arr.splice(i, 1)[0];
       if (arr.length === 0) set.push(memo.concat([cur]));
       permute(arr.slice(), memo.concat([cur]));
       arr.splice(i, 0, cur);
    }
    return set;
 }
 return permute(input);
}
Posted by: Guest on February-02-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language