Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: (GOLF) combine N arrays

by jynx (Priest)
on Apr 16, 2002 at 21:22 UTC ( [id://159629]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    sub combinations {
    #58+58=116
    ...
    my@a;$;=@{$_[0]}**@_;while($a=pop){$==0;for$a((@$a)x($;>>(  
    $b=@$a**@_)||1)){push@{$a[$=++]},$a for+1..$b}}@a[0..$;-1]
    }
    
  2. or download this
    sub attempt2 {
    #66+65=131
    ...
    my%a;$-=(@_=sort{@$b<=>@$a}@_);$;=1;map$;*=@$_,@_;while($a=pop){$=
    =0;for$a((@$a)x($;/@$a)){push@{$a{$=++}},$a}}grep$-==@$_,values%a
    }
    

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (4)
As of 2024-04-24 06:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found