Skip to content

Instantly share code, notes, and snippets.

@rohit012
Created October 22, 2017 03:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rohit012/8480faa4585c30668d8b58e71a30ade8 to your computer and use it in GitHub Desktop.
Save rohit012/8480faa4585c30668d8b58e71a30ade8 to your computer and use it in GitHub Desktop.
Combinations of string characters all unique
var combinations = function(str) {
var arr = str.split('');
for( var i=0; i< arr.length; i++){
genComb(arr, i+1);
}
}
function genComb(arr, length, str, index) {
str = str || '';
index = index || 0;
if(str.length === length) {
console.log(str, length);
return;
}
for(i=index; i<arr.length; i++){
genLenPermu(arr, length, str+arr[i], i+1);
}
}
combinations('aaa');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment