Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Combinations with variable length

by Anonymous Monk
on May 10, 2021 at 22:14 UTC ( #11132357=note: print w/replies, xml ) Need Help??


in reply to Combinations with variable length

$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"; }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11132357]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (3)
As of 2021-08-04 16:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My primary motivation for participating at PerlMonks is: (Choices in context)








    Results (41 votes). Check out past polls.

    Notices?