Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: array problems

by ido50 (Scribe)
on Aug 12, 2003 at 16:37 UTC ( [id://283255]=note: print w/replies, xml ) Need Help??


in reply to array problems

Will be nice if you put the code you already have here.

-------------------------
Live fat, die young

Replies are listed 'Best First'.
Re: Re: array problems
by bfish (Novice) on Aug 12, 2003 at 18:25 UTC

    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?

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (7)
As of 2024-04-18 08:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found