Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: knapsack problem solved by regex

by jwkrahn (Monsignor)
on Mar 15, 2010 at 18:19 UTC ( #828763=note: print w/ replies, xml ) Need Help??


in reply to knapsack problem solved by regex

On a hunch I changed:

for ( keys %items ) {

To:

for ( sort { $items{ $b }{ v } <=> $items{ $a }{ v } } keys %items ) {

Which produced a nice speed-up compared to the default hash order.

Note that the converse of:

for ( sort { $items{ $a }{ v } <=> $items{ $b }{ v } } keys %items ) {

Was a lot slower than the default hash order.


Comment on Re: knapsack problem solved by regex
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (8)
As of 2015-07-06 10:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (71 votes), past polls