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

I'm having a hard time understanding Problem#4 in Problem Set 6. can anyone explain the given pseudocode ?

OpenStudy (anonymous):

2008 or 2011?

OpenStudy (anonymous):

Fall 2008. Problem "faster computer player" for the word game. There's a 2011 version ?!

OpenStudy (anonymous):

first, you make a dictionary of the word list where the keys are the word whose letters have been sorted and the values are the word - the entry for 'fake' would be {'aefk' : 'fake'} then you create a function that will: - generate all possible combinations of the letters in the hand in 'groups' of 2, 3, 4 --> length of hand - using these combinations, determine which has the highest point value if it is a word fake combinations of fake ae af ak ef ek fk aef aek afk efk aefk how did you solve problem 3 - pick_best_word ??

OpenStudy (anonymous):

Thanks bwCA. I applied that and it finally works, but it's really slow ! (much slower than problem 3 - pick_best_word). I am trying to figure out what's making it so slow but without success so far. And there's something else about this solution: what if two words share the same "sorted format" ? for example "aemt" is the sorted format for both "meat" and "mate" and what happens with this code is that the last word being matched to "aemt" is the only one that gets stored. I tried to get over this by making the values in list format and appending words to them, but this made it terribly slow and when run it seemed it would never stop ! am I missing something here ? This is how I solved problem 3 - pick_best_word for every word in points_dict: if all characters of points_dict exist in the hand: store this word's score if this word's score > best score: set best score to this word's score P.S: For getting the possible combinations of the letters of a hand, I used the itertools.combinations() method.

OpenStudy (anonymous):

i think they expected us to use permutations of the letters in hand for problem 3 then realize that since the letters are sorted in problem 4 that we only had to use all the combinations. there are a lot less combinations than permutations - and we were supposed to learn that a bit of pre-processing and choosing different data types can affect execution time. it least that's what i think.

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!