Created
January 19, 2018 08:58
-
-
Save ice2heart/f32d6f3c3ca8b41b7bdb7e05abf43635 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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