anonymous
  • anonymous
how to open the wordlist in problem set 5? (to check the words and stuff?) heeeeeeeeeelp!!!!
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.
jamiebookeater
  • jamiebookeater
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
anonymous
  • anonymous
You should be able to open it with a standard text editor. I'm not sure what your question is asking?
anonymous
  • anonymous
w0000t a reply!!! thanks. my problem is , when i open it in a text editor it comes up with no spaces between the words. if i understand the code (which i probably dont) then i think it puts all the words in a list. I try opening this list in IDLE, but it just crashes IDLE. We are supposed to end the game of Ghost when it not possible to continue and make aword. The only way i could think to do that was to hopefully open up the wordlist (as an ordered, alphabetical list) and try and do something with that.
anonymous
  • anonymous
is watching polpak type reply

Looking for something else?

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

More answers

anonymous
  • anonymous
I think there are probably newlines between the words, but depending on your editor you may not be able to see them. You don't need to open or read or change the word list in any way to do the problem set, I you can simply use the functions they provide in the assignment.
anonymous
  • anonymous
btw, I'm in group chat right now if you'd rather discuss this interactively
anonymous
  • anonymous
I am pretty sure that the words in the list are separated by spaces, zohaibkhan. My solution for the Ghost problem included a function that checked the list for word fragments with a space concatenated to the front to make sure that the current string was able to from a word.I think I tested it with and without the concatenation to make sure.
anonymous
  • anonymous
Wpaprocki, thanks for your reply. I have solved the problem now, but i think my solution is kinda dirty. here was my method: Basically i take the current letters(that have been selected by players) and then I append them (as a string) to the wordlist. then i sort the list. then i find the index of the entry I made. then i check if the next entry in the wordlist starts with the string i entered into the wordlist. If it does not, then the game ends cause no words possible with that combo of letters. Oh yeah, then i make sure that i remove the entry i made to the wordlist. (i should have joined this place earlier, its nice to discuss the problems)
anonymous
  • anonymous
That seems like a fairly complicated solution. Why not simply iterate the wordlist looking for any entry that starts with the fragment the players have so far. wordFound = False fragmentFound = False for word in wordlist: if word == fragment: wordFound = True break if word.startswith(fragment): fragmentFound = True if wordFound or not fragmentFound: print "The game is over"
anonymous
  • anonymous
Actually, I just checked the code again. I forgot that I had changed the wordlist document into a string with the join method and with a space as a delimiter. Basically, I just put all the words into one long string with a space in between each word. Then I checked each fragment against the list by concatenating a space to the front and counting the number of times that it appeared in that form. If it appeared zero times, then that ended the game. I suspect polpak's solution is probably more efficient because it doesn't check the entire list. def check_frag(fragment): '''checks to see if word fragment can form word''' wordstring = join(wordlist," ") if wordstring.count(" "+fragment) == 0: return False return True
anonymous
  • anonymous
Yeah...polpak makes sense. i don't know why i didn't think of that, seems so straightforward now. thanks for your solution too, Wparocki.

Looking for something else?

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