not perfect, but still::: http://dpaste.com/568153/ it runs fine on smallCatalog, but when i give it subjects, it goes over maxWork.... the calculations are right, but I think Im not storing the class names correctly......
incorrectly*
when you pass the list 'c' to each new function instance a new list instance is NOT created - c always points to the same (original) list object. So every time a function instance executes c.append(), something gets added to that list object. that might be the problem (probably is) I kept track of and memoized indices only - because of this, when i needed to compare the value of two lists of indices, i had to figure out what their value was - i wrote a seperate function for this and called it when comparing. http://dpaste.com/568242/ you could probably do this with the subject names also - keep track of and memoize subject names taken then use the subjects dictionary to tally up the value. this problem is a knapsack problem, but unlike the solution demonstrated in the lecture this solution requires that you keep track of the items taken - pretty sure that the lecture example only kept track of the total value. so this solution has to be a little different. you have to keep track of the things you are taking AND you have to be able to determine their value maybe goodbye will chime in, looks like he/she got thru this one - it would be nice to have some more perspectives
looks like nessman also got past this maybe he/she has an idea ...
first I'd like to say it amuses me that you (bwCA) still use he/she with someone with the word man in his internet name. secondly bwCA more or less helped me finish this off when i was having issues, i was trying to record to much info in the memo, in the end I stole his branch_value and just saved a list of indexes I'm having trouble reading your code (granted its 5:30 AM and i have yet to sleep), your list c is just getting in the way of things. your returning a the course value and keeping track of the indicies independently , I've tried that (mentioned above, these paragraphs were written out of order) and it doesn't go so well. you have to try and make your code do as little as possible my personal code had me returning [index] + dpAdvisorHelper(...) or just dpAdvisorHelper(...) base case return [index} or [] (with or without_index respectively) so it was just a plain list of indexes, I ran them through bwCA's branch value code and compared those two values, brings me to my last point lastly and least of all, I found passing fewer arguments between function calls worked for me, all the lists were created within the function so i didn't need to pass one in,(removes c) without splitting the tuple i passed the list of work,value pairs on its own, a list created by subjects.values(), (replaces courseVal, and courseWork with a single argument, I called mine Value) At the top of your program the professor wrote a quick assignment statement so you only need Value[WORK] or [VALUE] to get what you want, found it handy. Values[I][WORK] is a perfectly valid call ok this feels totally unreadable but I'm putting it out there in case it makes sense and you get back and read this before I do
hahaha. thanks,u I haven't had internet access for a few days due to traveling and during that time I got it all worked out http://dpaste.com/570419/ V(>_<)V There is probably some optimization that could be done i the dpAdvisor function but we'll just go with ths for now @/' <-----snail
Does it work with subjects with 320 items? The link has expired Mine takes a lot of time when I try anything above 10
@Shiram, you should start a new topic and post your code ... use dpaste.com or pastebun.com or codepaste.com ....
I thought of that but posting it here i thought would make it easier for many people to understand the context much easier and sooner
post what you have - use a code pasting site that has syntax highlighting;, it should not take 'a lot of time'. by continuing this 'thread' most people will not see it - the only reason i saw it is because i was part of the discussion 3 mos ago and i got a heads up that someone had posted to it.
Ok, i've posted it @ http://openstudy.com/?F1282357741635X41PDL=_#/updates/4ea8c6a8e4b02eee39cd5493
Join our real-time social learning platform and learn together with your friends!