I simply cannot wrap my head around how to solve this problem and after a thorough search on Google with no results, I turn to you with hopes of a solution.
Given the sa
Just for those wanting a PHP translation:
function factor_permutations($lists) {
$permutations = array();
$iter = 0;
while (true) {
$num = $iter++;
$pick = array();
foreach ($lists as $l) {
$r = $num % count($l);
$num = ($num - $r) / count($l);
$pick[] = $l[$r];
}
if ($num > 0) break;
$permutations[] = $pick;
}
return $permutations;
}
print_r(factor_permutations(array(array('a', 'b'), array('1', '2', '3'), array('foo', 'bar'))));