Well, actually, I haven't coded the whole thing...it was just looking ugly as I started...I started out thinking I'd just check to see if I could find two of my picks that would be roughly the same value as the other guys pick, so here is the code I had:
foreach my $rec1 (@to_trade1) { foreach my $rec2 (@to_trade1) { if ($rec1->{"PICK"} != $rec2->{"PICK"}) { my $trade_diff = $pot_trade_val - $rec1->{"VALUE"} - $rec2->{" +VALUE"}; if (($trade_diff > 49) && ($trade_diff < 101)) { $to_trade[$trade_cntr]->{"PICK_LIST"} = sort {$a <=> $b} ($r +ec1->{"PICK"}, $rec2->{"PICK"}); $to_trade[$trade_cntr]->{"VALUE"} = $trade_diff; }
That should give you the idea of where I was going with the following understanding:
| $pot_trade_val | The value of the pick I want plus the 16th round pick held by the same team |
| $rec1 and $rec2 | The same array copied twice and this is the list of picks I currently have. |
| $to_trade | This is the set of picks that is within my tolerance to trade 50-100 points difference, of course, I'd walk this list and pull the one closest to 50 |
So, as I was going through this, I thought that it would end up pretty ugly and I'd only be able to account for say groups of three picks before the logic gets even worse. Thus, I thought it might be easier to value all my picks once, and then each time I was looking for a trade, I could just grep and sort the array of already calculated values! Sound like a good approach?
In reply to Re: Re: array problems
by bfish
in thread array problems
by bfish
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |