Created
October 22, 2012 06:56
-
-
Save THEtheChad/3930037 to your computer and use it in GitHub Desktop.
My shitty attempt at a recursive permutation algorithm.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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