Hey guys - I'm on problem set 8, problem 2, the greedy advisor function and it looks like my function is not accurately comparing items in the dictionary. It might also not be storing them correctly, but I was hoping someone could take a look and give me some pointers. Thanks!! http://codepad.org/4KGYyR85
i didn't have time to look at your code but .... you want to run thru the classes and pick the one with the highest value when you pik one, you don't want to use it again - you can either delete it from the 'source' dictionary or add a conditional to the comparison like subject not in chosen_classes everytime you pik a class, decrement max_work go back and do it again and again untill you run thru the complete set of subjects and don't find one that meets the criteria.
Yeah, I appreciate the summary of the problem bwCA - this is what I think the code is supposed to be doing. It just looks like it's not comparing / storing answers correctly and I don't know why. I'm going to take another stab at it now though and I'll update this question if I solve it. Thanks though / let me know if you have time to look through it
Problems solved - I think that indexing on dictionaries is just more dangerous that I originally believed. It was apparently resorting the dictionary of classes every time I was comparing something and that made it really hard to track whether or not it was working. Turning everything into lists and adding the results back into the dictionary helped tremendously. Thanks anyway though!
thats what i did - turned the dictionary into three lists and then worked with the lists... http://dpaste.com/744774/
Join our real-time social learning platform and learn together with your friends!