Gina is traveling with Tom into the desert, and she'll be carrying all of their food. She can carry a maximum of and has of space to carry supplies in her bag. Gina can pick from the following collection of supplies:
Food item - Weight / Volume / Calories
What is the largest number of calories she can bring with them, given her constraints?
Note: Gina can bring as many as she wants of each of the above items.
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
Same solution as Part 1 ,except we have two constraints this time. I again used recursion with memoizaion because I was too lazy for a D P solution.If MaxCals is the maximum amount of calories for a given Weight and Volume limit then it can be defined recursively as
M a x C a l s = m a x ( M a x C a l s ( W e i g h t − w 0 , V o l u m e − v 0 ) , M a x C a l s ( W e i g h t − w 1 , V o l u m e − v 1 ) . . . )
for some weight,volume pair ( w i , v i ) in the set of supplies.