Ask your own question, for FREE!
MIT 6.00 Intro Computer Science (OCW) 16 Online
OpenStudy (anonymous):

I'm a little frustrated with the dynamic adviser on Problem Set 8. I have my code working but it is ridiculously slow. I think it has to do with the fact that I'm making a copy of the dictionary with every recursion but I don't know how else to be able to delete selected entries before passing without destroying the original dictionary. Also, as it is, I am storing the total work and value within the dictionary which also shows up in the printSubjects(). I feel like both of these problems could be fixed easily if we were able to pass anything more than the dictionary http://dpaste.com/608012

OpenStudy (anonymous):

i have a helper function dpAdvisorHelper. dpAdvisor makes three lists (subject names, work, value) from the dictionary and passes two of them to the helper function. The helper function does all the work and returns an answer to dpAdvisor. i pass other things to the helper function also. here is my helper function definition: http://dpaste.com/608180/

OpenStudy (anonymous):

Oh MAN! I didn't know that was ok to do in the assignments! That makes it so much easier but I figured if we were meant to implement the code in that one function, I should be able to figure out how to make it work. Did he mention the use of helper functions and I just missed it?

OpenStudy (anonymous):

the bruteforce advisor had a helper function. encapsulating functionality in functions seems to be a desirable thing. one way to think about it is - someone asks you to write a function that does x when passed y and z as arguments - that person is going to use that function to do something and as long as you maintain that 'interface' (y and z as arguments) your function can do anything it wants to solve the problem - including calling other functions. in fact if you have helper functions, you can go back later and playaround with those without breaking that original interface - hope that made sense. i really doubt there are any limitations to solving the problems except those given in the problem instructions.

OpenStudy (anonymous):

You may also do it without any helper functions. http://codepad.org/1rQBxasq

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!