Here is what I came up with (I'm just using the example of the operator "+" because that is the only one I _need_ right now):

use List::Util; use Algorithm::ChooseSubsets; ...<lots of stuff snipped here>... # Generate sums of the values of all combinations of my picks my @to_trade1; for (my $i=0; $i < $roster_spots; $i++) { my $record={}; my $this_pick = $pick_by_team[$brett_team][$i]; if ($this_pick > $draft_pick) { push @to_trade1, $this_pick; } } my @to_trade = {}; for (my $i = 2; $i < $#to_trade1; $i++) { my $subset_list = new Algorithm::ChooseSubsets(\@to_trade1, $i); while (my $this_set = $subset_list->next()) { my $record={}; $record->{"LIST"} = [ @$this_set ]; $record->{"VALUE"} = List::Util::sum @$this_set; push @to_trade, $record; } } print Dumper(@to_trade);

This works, but is pretty slow...I have to respond to trades within a minute so, I may try some ways to speed it up!


In reply to Re: Re: array problems by bfish
in thread array problems by bfish

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.