$amount = 3; @pick = (1,2); @end = (); for($i=0;$i<$amount;$i++) { for($z=0;$z<2**($amount-1-$i);$z++) { for($j=0;$j<@pick;$j++) { for($k=0;$k<2**$i;$k++) { push(@{$end[$i]},$pick[$j]); } } } } for($z=0;$z<2**($amount);$z++) { for($i=0;$i<$amount;$i++) { print $end[$i][$z]."\t"; } print "\n"; }
In reply to Re: Combinations with variable length
by Anonymous Monk
in thread Combinations with variable length
by TryingTheBest
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |