anonymous
  • anonymous
I'm stuck on PS5_ghost, I've got it all except how to test for word fragments that will never become words. I noticed get_frequency_dict() in the given helper code, so I'm guessing that might be what I need. But I don't really see how that's going to help me. I'm thinking a search (binary or newton-Raphson) to see if it exists. Can anyone give me a clue?
MIT 6.00 Intro Computer Science (OCW)
  • Stacey Warren - Expert brainly.com
Hey! We 've verified this expert answer for you, click below to unlock the details :)
SOLVED
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.
chestercat
  • chestercat
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
anonymous
  • anonymous
the startswith() str method helps -> word.startswith(fragment) you could just run thru the word list i used a binary search
anonymous
  • anonymous
I'm not sure we learned that yet, I think we're still supposed to be doing this all from scratch still. But I think you're reply helped anyway, I'm going to try to make a function based on what you described.
anonymous
  • anonymous
in case it helps, the get_frequency_dict() function is this one: def get_frequency_dict(sequence): """ Returns a dictionary where the keys are elements of the sequence and the values are integer counts, for the number of times that an element is repeated in the sequence. sequence: string or list return: dictionary """ # freqs: dictionary (element_type -> int) freq = {} for x in sequence: freq[x] = freq.get(x,0) + 1 return freq

Looking for something else?

Not the answer you are looking for? Search for more explanations.

More answers

anonymous
  • anonymous
I didn't need to use get_frequency_dict for ghost. this is not a class in Python. You need not restrict yourself to the portions of Python that they expose to you in the lectures. There is no difference between using the startswith() method and constructing a slice of the word to compare with the fragment

Looking for something else?

Not the answer you are looking for? Search for more explanations.