Created
May 7, 2018 23:36
-
-
Save adrianhorning08/29ed92f824579d8f6beb28e84a436534 to your computer and use it in GitHub Desktop.
Cartesian Product of Products
This file contains 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
function printCombos(array) { | |
var results = [[]]; | |
for (var i = 0; i < array.length; i++) { | |
var currentSubArray = array[i]; | |
var temp = []; | |
for (var j = 0; j < results.length; j++) { | |
for (var k = 0; k < currentSubArray.length; k++) { | |
temp.push(results[j].concat(currentSubArray[k])); | |
} | |
} | |
results = temp; | |
} | |
return results; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment