In PS6, q3 (implementing a computerized player), we have to create the dictionary to map words to points. Intuition tells me that I should only do this once (process is n^2 at least (n in length of word_list, at least n in conversion operation). get_word_score is presented to us in ps5 handling bingos internally (if len(word) == n, the hand length). Since the n will change constantly as we play letters, what constitutes a bingo will change accordingly (the hand length is constantly reducing). If the point value for words are constantly changing, do we have to call it once/hand?
The complexity if the process is O(n), because you only have to loop through all the words. For each word, you have to go through the letters to go through all letters to compute the points. But this is negligible because it's a very small number. A bingo occurs when you find a word using all the letters at the first try, not with subsequent tries. And you are right, it should be called just one time.
the point values for words do not change - they are always the same, - they are dependent on the letters in the word and the spelling isn't variable.
maitre: that's the piece I was missing- that it's only if len(word) == HAND_SIZE, not len(hand). It was hidden in a single word in assignment 5. Thanks.
Join our real-time social learning platform and learn together with your friends!