Last active
February 1, 2017 17:02
-
-
Save brunofurmon/3b4ef241d825c54fc19f99330d3304f0 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
// Combination of 2. | |
// Took about 1 second with an array with 1000 unique ints | |
var a = [0,1,2]; | |
var combs = []; | |
var combinationOf2 = function(a) | |
{ | |
var combs = []; | |
var size = a.length; | |
for (i = 0; i < size-1; ++i) | |
{ | |
for (j = i+1; j < size; ++j) | |
{ | |
// | |
combs.push(a[i] + '-' + a[j]); | |
} | |
} | |
return combs | |
} | |
// Returns [0-1, 0-2, 1-2] | |
combinationOf2(a); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment