Open study

is now brainly

With Brainly you can:

  • Get homework help from millions of students and moderators
  • Learn how to solve problems with step-by-step explanations
  • Share your knowledge and earn points by helping other students
  • Learn anywhere, anytime with the Brainly app!

A community for students.

Hi, I'm on problem set 5 problem 6: implementing the game 'ghost'. I have two questions. 1) The 'Helper Code' includes a function to convert the string to a dictionary, is it easier to work with dictionaires in this problem and why? 2) A rule in the game is that players must create word fragments that can become words, how do I search the wordlist to check this?

MIT 6.00 Intro Computer Science (OCW)
See more answers at
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.

Join Brainly to access

this expert answer


To see the expert answer you'll need to create a free account at Brainly

MIT OCW 2008?? my solution does not use the frequency dictionary function the startswith() string method may be usefull. I used a bisection search of the wordlist to see if a fragment could make a word
I used the str.startswith and it worked. I haven't done a bisection of the wordlist because I found that an answer was return straight away with "any (w.startswith(frag) for w in wordlist)". although I imagine a bisect seach would be more efficient
yeh OCW 2008

Not the answer you are looking for?

Search for more explanations.

Ask your own question

Other answers:

keep it simple, if it works and its not to slow it's ok. nice generator.
1) Dictionaries are a mapping between a key and a value. Your variables are actually a dictionary: foo = 3 foo is the key, 3 is the value. When you want foo's value, you just refer to foo. Most of the rest of it is just syntax stuff. One thing that isn't much fun with dictionaries, if you refer to a key that doesn't exist, they raise an exception. The good news, is that dictionaries have method to query them that won't raise an exception: foo = dict.get( key, sentinalValue ) if( foo == sentinalValue ): print "shucks!" else: print "you got key's value"

Not the answer you are looking for?

Search for more explanations.

Ask your own question