anonymous
  • anonymous
I'm on problem set 6 trying to find all subsets of letters in hand. I found and implemented itertools successfully, but I haven't been able to write my own code that does the same thing. I'm basically looking at the itertools.combinations code and trying to mimick what it's doing without the yeild function, since the course hasn't covered it yet. If you run my code you can see where it goes wrong from the print statements, but I can't spot how the itertools.combinations code is solving the problem. code here: http://pastebin.com/keQzLrXU
MIT 6.00 Intro Computer Science (OCW)
  • Stacey Warren - Expert brainly.com
Hey! We 've verified this expert answer for you, click below to unlock the details :)
SOLVED
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.
schrodinger
  • schrodinger
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
maitre_kaio
  • maitre_kaio
what's up with this syntax? shouldn't else be indented? Valid statement in Python, I agree with you that is rather unusual (http://docs.python.org/tutorial/controlflow.html#break-and-continue-statements-and-else-clauses-on-loops)
maitre_kaio
  • maitre_kaio
Concerning the yield keyword, pretty new for me, I found a clear (as clear as possible) explanation here: http://stackoverflow.com/questions/231767/the-python-yield-keyword-explained
anonymous
  • anonymous
just because something hasn't been covered in lecture doesn't mean you can't use it. this isn't a Python class, it is a CompSci and Programming class that uses Python. If you find something useful in the language, use it. worked for me. http://dpaste.com/696593/

Looking for something else?

Not the answer you are looking for? Search for more explanations.

More answers

anonymous
  • anonymous
wow. It took me an incredible amount of time to understand the itertools.combinations code. Thanks for pointing me to the python documentation maitre -- 4.4 shows you can use else to close off a for loop. Weird. I've worked out some code that uses the same method minus the yield function, plus some handy print statments to make clear what's going on inside: http://pastebin.com/JaKLFt8y . bwCA: I understand it's a CS class and not a Python class, but isn't that a reason to complete the excercises without using python functions that haven't been dicussed in the lectures? With that said, I am a little frustrated that there was nothing discussed in the lectures that helps solve the subsets problem. There was plenty on sorting, so that part of the exercise was feasible, but there is NO WAY I could have come up with the above pasted code on my own based on just the lectures and reading materials.
anonymous
  • anonymous
Six3, Remember that the class was designed for MIT students. It wasn't designed for a youtube audience so there probably are gaps. That's part of the tradeoff of a free class. With that said, I think the subset problem can be solved with what's been taught through lecture 10. I don't think one needs to use itertools.
anonymous
  • anonymous
http://dpaste.com/697083/

Looking for something else?

Not the answer you are looking for? Search for more explanations.