Can someone please give me any hints to Q4 in ps8?? I am horribly stuck. I understand how the recursive helper function used in Q3 works and am using a slightly modified version of it. I do not know what to memoize. Right now I am memoizing the counter/index (i) and subsetWork values.
if you want to look at my code for Q4, please use the above link
I will have alook at your code. This was one of th emost tasking problems I've seen in this course so far. Here's how I solved it. (I got clues from looking at other people's soluiton). http://pastebin.com/QQRmkQvS
srry for double posting.
thank you so much mercutio22......this problem was certainly killing me. I am wondering if the guys at ocw should consider changing their implementation of bruteforceadvisorhelper function to make life easier for students as it is really very tough to understand that implementation and convert it into one that uses dynamic programming. But maybe my approach was wrong and I should have tried to use my own implementation variant in dpadvisorhelper rather than copying the one provided in bruteforceadvisorhelper. Thanks once again. Now that I know that this problem CAN be solved I will try coding my own implementation variant with dynamic programming.
Alright, glad to know that was helpful. Tell me if there's anything in my code you don't understand. The trick is creating not only a memo to remember the best value achievable but also another memo to remember the item combo that achieves it.
Join our real-time social learning platform and learn together with your friends!