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
    }