View Single Post
  #15  
Old 08-29-2007, 01:12 AM
m_the0ry m_the0ry is offline
Senior Member
 
Join Date: Aug 2006
Posts: 790
Default Re: A Math Problem (NP Complete?)

Sorry I didn't really answer your OP's question...

First to clarify the problem, you want to maximize calories with using at least 1 item from each category with the total cost <$10.

My question is why you subtract the stats of the highest cal/$ item from the rest. I was assuming that the prices and calories listed are of the lowest denomination. I think I'm not understanding some critical part of your algorithm here. A few potential problems arise from this step because we can very easily corrupt our data. For example you would commonly get a negative cal, negative price, or both, or even worse a divide by zero. This really messes with the algorithm and the way it does comparison. If we have an item with a good ratio but low stats, it will be quickly corrupted by this process (66cal for $.33 for example) but any time the best ratio item has more calories or more cost associated with it than another, something bad will happen.
Reply With Quote