I have this relatively complex combinations and permutations code that I have to execute in CLI. The code takes a number as command line parameter and then outputs a list of all permutations of all unique combinations. The arrays are strings of numbers separated by a space.
The code works nice if N is 6 or less. Even 7. However when I pass n=8 the code simply freezes,, it stops and doesn’t move on.
How can I fix this so that N can be 8.
N will never be larger than 8, BUT the code must be able to execute with 8.
Here is the code
for ($i=0; count($list) < $nop; $i++) {
shuffle($array);
$tmp = implode(' ', $array);
if (!isset($list[$tmp])) {
$list[$tmp] = 1;
}}
Thanks for all advice in advance.
causes an infinite loop. Nowhere in the loop does the size of
$listor$nopchange so ifcount($list) < $nopis true, it’ll be an infinite loop.