Quantcast

Got Homework?

Connect with other students for help. It's a free community.

  • across
    MIT Grad Student
    Online now
  • laura*
    Helped 1,000 students
    Online now
  • Hero
    College Math Guru
    Online now

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

Dordan Group Title

How come my comp_choose_word function is randomly stopping at sow for 18 points?

  • 3 months ago
  • 3 months ago

  • This Question is Open
  1. Dordan Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    Here is my code, I have clearly shown that the word fast generates more points than the word sow. And it isn't even finding any words past 3 characters. I think something is wrong with the get_perms function. def comp_choose_word(hand, word_list, n): high_score = 0 for length in range(1, n+1): print 'Length:',length for word in get_perms(hand, length): print 'Trying',word if get_word_score(word, n) > high_score: print 'Found higher word',word if is_valid_word(word, hand, word_list): print word,'is valid' high_score = get_word_score(word, n) high_word = word else: print word,'is not valid english word' print high_word,':',high_score hand = {'a':1,'s':1,'t':2,'w':1,'f':1,'o':1} comp_choose_word(hand, word_list, 7) print 'Fast for',get_word_score('fast', 7),'points'

    • 3 months ago
  2. seandisanti Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    Where are you declaring high_word?

    • 3 months ago
  3. Dordan Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    high_word = word

    • 3 months ago
  4. Dordan Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    Anyone? I'd really like to move past this problem set, it's been a week now.

    • 3 months ago
  5. NixonInnes Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    Dordan, I'm afraid I can't really help you without taking a look at all of your code. Could you please stick it into a http://pastebin.com/ or something similar?

    • 3 months ago
  6. Dordan Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    Here's ps3a: http://pastebin.com/ewFih5vg and part of ps3b which I'm working on right now, the rest is not needed since I am not that far in ps3b yet: http://pastebin.com/EK8DC7Xa

    • 3 months ago
  7. Dordan Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    This type of error is completely new to me. Whenever I've encountered an error in the past, it is either obvious and causes the program not to run, or it just gives back faulty or no results. Never partial results, and I've gone over the pseudocode for both of my files and even tried to partially understand the perm file, but it all seems to make sense to me logically.

    • 3 months ago
  8. NixonInnes Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    Hey Dordan, I managed to have a quick go through your ps3a tonight, I know your original question related to the Part B, but we need this to be rickety-tick before we move on to that. I've made some changes to mainly play_game() and a few bits and bobs about the place. I put in comments about my changes. Let me know how you get on. I tested it several times, with no problems (other than my IDE's ipython hanging sometimes times... which i think is the IDE misbehaving...). I think that there are a bunch of test functions in the problem set zip; I didnt get time to fire them up though. http://pastebin.com/sSGVMWB1

    • 3 months ago
    • Attachments:

See more questions >>>

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.