Skip to content

Instantly share code, notes, and snippets.

@ice2heart
Created January 19, 2018 08:58
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 ice2heart/f32d6f3c3ca8b41b7bdb7e05abf43635 to your computer and use it in GitHub Desktop.
Save ice2heart/f32d6f3c3ca8b41b7bdb7e05abf43635 to your computer and use it in GitHub Desktop.
const data = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26];
let variants = [];
const f = function (res, i) {
if (i > data.length - 1){
variants.push(res);
return;
}
let res1 = res.slice();
f(res1, i+1);
let res2 = res.slice()
res2[i] = data[i];
f(res2, i+1);
}
f([], 0);
console.log(variants.length);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment