Ask your own question, for FREE!
MIT 6.00 Intro Computer Science (OCW) 9 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!
Latest Questions
Arriyanalol: i need help
1 day ago 7 Replies 1 Medal
Arriyanalol: CONGRATS to me
1 day ago 8 Replies 2 Medals
Legomaster346: What colleges are good that are near Arab Alabama?
1 week ago 5 Replies 0 Medals
Arriyanalol: i need help
1 week ago 6 Replies 2 Medals
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!