Skip to content

Instantly share code, notes, and snippets.

@jinwolf
Last active December 19, 2015 09:10
Show Gist options
  • Select an option

  • Save jinwolf/f9f57b359c89665a549e to your computer and use it in GitHub Desktop.

Select an option

Save jinwolf/f9f57b359c89665a549e to your computer and use it in GitHub Desktop.
All possible unique combination of a given string
var combo = (function() {
var charList;
function doCombo(buffer, start) {
for (var i = start; i < charList.length; i++) {
buffer.push(charList[i]);
console.log(buffer.join(''));
doCombo(buffer, i + 1);
buffer.pop();
}
}
return function(str, k) {
charList = str.split('');
doCombo([], 0);
}
})();
combo('abc');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment