A community for students.

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

anonymous

  • 5 years ago

how to open the wordlist in problem set 5? (to check the words and stuff?) heeeeeeeeeelp!!!!

  • This Question is Closed
  1. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    You should be able to open it with a standard text editor. I'm not sure what your question is asking?

  2. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    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.

  3. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    is watching polpak type reply

  4. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    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.

  5. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    btw, I'm in group chat right now if you'd rather discuss this interactively

  6. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    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.

  7. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    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)

  8. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    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"

  9. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    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

  10. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    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.

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

    • Attachments:

Ask your own question

Sign Up
Find more explanations on OpenStudy
Privacy Policy

Your question is ready. Sign up for free to start getting answers.

spraguer (Moderator)
5 → View Detailed Profile

is replying to Can someone tell me what button the professor is hitting...

23

  • Teamwork 19 Teammate
  • Problem Solving 19 Hero
  • You have blocked this person.
  • ✔ You're a fan Checking fan status...

Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.

This is the testimonial you wrote.
You haven't written a testimonial for Owlfred.