Conversation
spitsfire
left a comment
There was a problem hiding this comment.
Elly and Ro, nicely done! My one suggestion is potentially shortening the helper function names, so it is more easily read inside the max and min functions.
| pass | ||
| import random | ||
|
|
||
| def draw_letters(): # Time complexity: O(1) Space complexity: O(1) |
There was a problem hiding this comment.
wow! you added the space/time complexities! very cool!
| for i in range (10): | ||
| random_letter = random.choice(list_letters_pool) | ||
| list_letters_drawn.append(random_letter) | ||
| # remove the drawn letter from the original list of letter pool after | ||
| # each random draw | ||
| list_letters_pool.remove(random_letter) | ||
| return list_letters_drawn |
There was a problem hiding this comment.
nice! another way you could do this is with a while loop! run the loop until the length of list_letters_drawn is 10
| if each_char in letter_bank_dict and char_count <= \ | ||
| letter_bank_dict[each_char]: | ||
| continue | ||
| else: | ||
| return False |
There was a problem hiding this comment.
while this is valid, continue statements aren't commonly used. We can dry this up by doing something like:
| if each_char in letter_bank_dict and char_count <= \ | |
| letter_bank_dict[each_char]: | |
| continue | |
| else: | |
| return False | |
| if each_char not in letter_bank_dict or char_count > \ | |
| letter_bank_dict[each_char]: | |
| return False |
| "Z" : 10, | ||
| } | ||
| score = 0 | ||
| for each_char in word.upper(): # unify the case of each char |
| # Time complexity: O(n) Space complexity: O(1) | ||
| dict_word_score = {} | ||
| for each_word in word_list: | ||
| dict_word_score[each_word] = score_word(each_word) |
| min_length = min((length_of_each_word_in_list_word_with_max_score(list_word_with_max_score))) | ||
| return helper_func_return_tuple_with_word_max_score(dict_word_score, min_length, max_score) | ||
|
|
||
| def helper_func_return_tuple_with_word_max_score(dict_word_score, length, max_score): # max or min length |
There was a problem hiding this comment.
👍 love a good helper function
| if len(each_word) == length: | ||
| return (each_word, max_score) | ||
|
|
||
| def length_of_each_word_in_list_word_with_max_score(list_word_with_max_score): |
There was a problem hiding this comment.
👍 glad you came up with some ideas on how to make your get_highest_word_score function stick to the solid principles
| list_letters_pool.remove(random_letter) | ||
| return list_letters_drawn | ||
|
|
||
| def uses_available_letters(word, letter_bank): |
| score += 8 | ||
| return score | ||
|
|
||
| def get_highest_word_score(word_list): |
No description provided.