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

PS 5, p6 [ghost()]: I am having trouble figuring out how to test if the word fragment can be a word, or if it is just jibberish. Testing if it is a word is simple ('if wordFrag in wordlist...), but testing if a fragment is potentially in wordlist is escaping me. Any direction would be much appreciated.

OpenStudy (anonymous):

You have to manually go through each word in the word list. Then for each one, ask if it starts with the fragment. You might find the string.startswith() method useful.

OpenStudy (anonymous):

Thanks, totally fixed it: http://codepad.org/CcBPoKcf if anyone wants to check out the code. I'm sure there is a better approach, but it works!

OpenStudy (anonymous):

binary search for fragment: http://dpaste.com/hold/634472/

OpenStudy (anonymous):

Ah yes. Of course!

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!