Skip to content

Instantly share code, notes, and snippets.

@THEtheChad
Created October 22, 2012 06:56
Show Gist options
  • Save THEtheChad/3930037 to your computer and use it in GitHub Desktop.
Save THEtheChad/3930037 to your computer and use it in GitHub Desktop.
My shitty attempt at a recursive permutation algorithm.
function permute(set, digits, prefix){
if(!prefix) prefix = '';
if(--digits){
var i = set.length;
while(i--){
permute(set, digits, prefix + set[i])
}
}
else{
var i = set.length;
while(i--){
permCount++;
console.log(prefix + set[i]);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment