Skip to content

Instantly share code, notes, and snippets.

@rohit012 rohit012/comb.js
Created Oct 22, 2017

Embed
What would you like to do?
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
You can’t perform that action at this time.