Did anyone else find the computation time for ps3b to be unreasonably long? As in, 20+ seconds on recent hardware/100% cpu?

Hey! We 've verified this expert answer for you, click below to unlock the details :)

I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!

how did you implement it? for a seven letter hand, you need to test for valid words using permutations of 1, 2, 3, 4, 5, 6 and 7 of the hand's letters. the number of permutations for each of those is n!/(n-k)!. 7!/6! + 7!/5! + 7!/4! + 7!/3! + 7!/2! +7! +7! = 13699 depending on how you implemented your search through the word list, it could get time consuming. there are ways to optimize. this is for the 2011 SC class? or 2008? http://en.wikipedia.org/wiki/Permutations#In_combinatorics

the part where it loads the words might take 2,3 seconds. the rest is pretty quick on my machine (my machine is kind of old and slow).

Spring 2011. Here's my implementation, omitting declarations: for n in reversed(range(0,HAND_SIZE+1)): #print n for w in get_perms(hand,n): if is_valid_word(w,hand,word_list): current = get_word_score(w,HAND_SIZE) if current > highscore: highscore = current bestword = w So, it runs the inner loop 13699 times, via seven trips through the outer loop, then for each execution of the inner loop checks against 83k words, which is in the neighborhood of a billion executions of get_word_score alone. I imagine that there's a much better way to do this.

Looking for something else?

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

## More answers

Looking for something else?

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