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

Re^3: knapsack problem solved by regex

by BrowserUk (Pope)
on Mar 14, 2010 at 18:05 UTC ( #828600=note: print w/ replies, xml ) Need Help??


in reply to Re^2: knapsack problem solved by regex
in thread knapsack problem solved by regex

Cool. I knew (guessed) it was too easy, but it worked for several test sets. Thanks for the explanation.

Actually, scrap the above, because according to the wikipedia page,

The most common formulation of the problem is the 0-1 knapsack problem, which restricts the number xj of copies of each kind of item to zero or one.

So you can't have 2 of one item?


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.


Comment on Re^3: knapsack problem solved by regex
Re^4: knapsack problem solved by regex
by rubasov (Friar) on Mar 14, 2010 at 18:29 UTC
    Think of the following: a solution to the 0-1 knapsack problem can be easily generalized to the bounded case, you just have to explicitly list the items with nr>1. Think of my previous example as this (just written abbreviated there):
    w v v/w 3 3.1 31/30 # case a 2 2 1 # case b (together with the following line) 2 2 1 # case b

      I see. Two different items with the same values and weights. Gotcha.


      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (6)
As of 2014-07-26 07:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (175 votes), past polls