Versionsvergleich

Aus ProgrammingWiki

Vergleich: 2017-07-07T08:02:24+00:00 → 2017-07-07T08:02:24+00:00

<language>Javascript</language>
<run id="595f4010527f3">
var permArr = [],
  usedChars = [];
function permute(input) {
  var i, ch;
  for (i = 0; i < input.length; i++) {
    ch = input.splice(i, 1)[0];
    usedChars.push(ch);
    if (input.length == 0) {
      permArr.push(usedChars.slice());
    }
    permute(input);
    input.splice(i, 0, ch);
    usedChars.pop();
  }
  return permArr
};
permute([1,2,3,4,5,6,7,8,9]);
</run>