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

RE: Unit 1 Quiz 1. The code for answer 4 doesn't do what the question is asking. I was building code that found words in the word list containing only letters found in the string. So 'abcd' would return 'bad'. Using the answer code and passing 'abcd' returns nothing because that code only finds words containing all of the letters in the string. Passing 'abd' would return 'bad', but instead of returning the word found, it returns the word after sorting, so passing 'abd' returns ['a', 'b', 'd']. Not very useful.

OpenStudy (anonymous):

Maybe I read too deeply into the question. I guess I was just disappointed by the answer after I spent a good chunk of time coming up with my own answer.

OpenStudy (anonymous):

... that contain each of the letters in lStr exactly once ... looks like they want words that will 'consume' all the letters in lStr seems like the function should return a list of the actual words that match NOT the sorted(word) - i would say their solution failed - all the items in their list would be the same, you wouldn't know what the words are. maybe something like this http://pastie.org/4859031 want to post your solution?

OpenStudy (anonymous):

What you have looks pretty good. I was thinking you could make a copy of 'w', sort and compare the copy and then append 'w' to 'result', but what you have is a bit cleaner. My original answer was getting pretty long since I was using nested loops to find all of the words in the word lists that you could spell using the letters in the string only once. So 'abcdef' would return 'bad', fad', 'cab' etc etc. I realized it was getting kinda long so I looked at their answer and realized I must have been doing more than it asked and was pretty disappointed in their solution.

OpenStudy (anonymous):

if you are tempted to finish what you started out of curiosity, you may want to consider using the itertools module, it makes generating combinations and permutations pretty painless - http://dpaste.com/808234/

OpenStudy (anonymous):

Looks interesting, thank you.

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!