Ask your own question, for FREE!
MIT 6.00 Intro Computer Science (OCW) 22 Online
OpenStudy (anonymous):

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

OpenStudy (anonymous):

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'

OpenStudy (anonymous):

Where are you declaring high_word?

OpenStudy (anonymous):

high_word = word

OpenStudy (anonymous):

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

OpenStudy (anonymous):

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?

OpenStudy (anonymous):

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

OpenStudy (anonymous):

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.

OpenStudy (anonymous):

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

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!