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

i got in trouble in the wordgame question, more specifically in the 'get_best_word_faster' part.how can i get all possible subsets of the letters of a hand? for now,what i can do is using quite a lot 'for' sentences to get them.there must be a better way.could anyone help me?

OpenStudy (maitre_kaio):

I used the itertools.combination() method of the itertools library to do that. http://docs.python.org/library/itertools.html#itertools.combinations I know some people here don't agree with me because they think that using a third-party library to do it is kindda cheating. My point of view is that it's not the point of this assignment. Choose your side :)

OpenStudy (anonymous):

hmmm, you must be looking at newer course material, the Fall 2008 handout doesn't have that

OpenStudy (anonymous):

yeah, I don't see that comment either. I found this problem extremely challenging, but it can be done without itertools. Here's a good example: http://codepad.org/SBwCIqFS (not my solution).

OpenStudy (anonymous):

here's a combination/multiset generator that makes use of string formatting http://dpaste.com/708751/

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!