Skip to content

Instantly share code, notes, and snippets.

@diestrin
Created September 6, 2014 16:15
Show Gist options
  • Select an option

  • Save diestrin/611674d58f31128864a1 to your computer and use it in GitHub Desktop.

Select an option

Save diestrin/611674d58f31128864a1 to your computer and use it in GitHub Desktop.
Hello combinations
(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