Created
September 6, 2014 16:15
-
-
Save diestrin/611674d58f31128864a1 to your computer and use it in GitHub Desktop.
Hello combinations
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 (word) { | |
| word = word.split(''); | |
| var combinations = [], max = factorial(word.length); | |
| function factorial (number) { | |
| if (number <= 1) return 1; | |
| return factorial(number - 1) * number; | |
| } | |
| !function () { | |
| var _word = word.sort(function (){ | |
| return Math.random() - 0.5; | |
| }).join(''); | |
| if (combinations.indexOf(_word) === -1) { | |
| console.log(_word); | |
| combinations.push(_word); | |
| } | |
| if (combinations.length < max) { | |
| setTimeout(arguments.callee, 0); | |
| } else { | |
| console.log('Ready'); | |
| } | |
| }(); | |
| })('abcde'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment