Conversation
spitsfire
left a comment
There was a problem hiding this comment.
Nicely done, Gricelda and Gabriela! There was only a few places I saw that I gave feedback on. Mainly just how to shorten up your code a little.
Good job!!
| } | ||
|
|
||
|
|
||
| def get_letter_frequency(letter_dict, letter): |
There was a problem hiding this comment.
👍 nice idea for a helper function! One thing I will say, LETTER_POOL already has a frequency for you, which you can reference immediately instead of making a new one.
| letters_count = {} | ||
| letters = list(LETTER_POOL.keys()) | ||
|
|
||
| while len(hand) < 10: | ||
| random_letter = random.choice(letters) | ||
| letters_count = get_letter_frequency(letters_count, random_letter) | ||
| letter_limit = LETTER_POOL[random_letter] | ||
|
|
||
| if letters_count[random_letter] > letter_limit: | ||
| continue | ||
|
|
||
| hand.append(random_letter) |
There was a problem hiding this comment.
This works fine! But I think we can save a little time by using the LETTER_POOL directly or by making a copy. And remember, if we take a letter away, then we need to subtract it from our pool of letters.
| letters_count = {} | |
| letters = list(LETTER_POOL.keys()) | |
| while len(hand) < 10: | |
| random_letter = random.choice(letters) | |
| letters_count = get_letter_frequency(letters_count, random_letter) | |
| letter_limit = LETTER_POOL[random_letter] | |
| if letters_count[random_letter] > letter_limit: | |
| continue | |
| hand.append(random_letter) | |
| letters = copy.deepcopy(LETTER_POOL) | |
| while len(hand) < 10: | |
| random_letter = random.choice(letters.keys()) | |
| if letters[random_letter] > 0: | |
| hand.append(random_letter) | |
| letters[random_letter] -= 1 |
| else: | ||
| continue |
There was a problem hiding this comment.
since this isn't doing anything for us, we can just remove it.
| else: | |
| continue |
| # print(letter) | ||
| # print(letter_bank[letter]) |
There was a problem hiding this comment.
Remember to get rid of print statements that are for debugging purposes
| # print(letter) | |
| # print(letter_bank[letter]) |
|
|
||
|
|
||
|
|
||
| def score_word(word): |
|
|
||
|
|
|
|
||
|
|
||
|
|
||
|
|
| @@ -1,11 +1,163 @@ | |||
| from operator import truediv | |||
There was a problem hiding this comment.
Hmm did you use this? I didn't see it. Let's get rid of it!
| from operator import truediv |
| return points | ||
|
|
||
|
|
||
| def get_highest_word_score(word_list): |
Gabriela and Gricelda finished Adagrams!