solver.js
// Given an array of arrays of strings, get all combinations of contents, with one selection per child array
Given an array of arrays of strings, get all combinations of contents, with one selection per child array
Given an array of arrays of strings get all combinations of contents with one selection per child array
function listCombinations(array, separator) {
		let numOfChoices = array.reduce((soFar, current) => {return soFar * current.length}, 1)
		let choices = []
		for (let choice = 0 ; choice < numOfChoices ; choice++) {
			let row = []
			let choiceVar = choice
			for (let subarray = 0 ; subarray < array.length ; subarray++) {
				let index = choiceVar % array[subarray].length
				row[subarray] = array[subarray][index]
				choiceVar = Math.round((choiceVar - index) / array[subarray].length)
			}
			choices[choice] = row.join(separator)
		}
		return choices
	}
function listCombinations ( array , separator ) { let numOfChoices = array . reduce ( ( soFar , current ) => { return soFar * current . length } , 1 ) let choices = [ ] for ( let choice = 0 ; choice < numOfChoices ; choice ++ ) { let row = [ ] let choiceVar = choice for ( let subarray = 0 ; subarray < array . length ; subarray ++ ) { let index = choiceVar % array [ subarray ] . length row [ subarray ] = array [ subarray ] [ index ] choiceVar = Math . round ( ( choiceVar - index ) / array [ subarray ] . length ) } choices [ choice ] = row . join ( separator ) } return choices }
Given an array of arrays of strings, get all combinations of contents, with one selection per child array
Given an array of arrays of strings get all combinations of contents with one selection per child array
// Iterate through all choices // With the choice we have, select one element from each subarray