Maple Ayaka and Grace(Jiajia Wang) #40
Conversation
spitsfire
left a comment
There was a problem hiding this comment.
Ayaka and Grace, great job! Your problem solving was very inventive. I liked lines 47 and 48, where you simplified the nested for loop and made it more readable actually! Very nice!
Keep up the great work, you two!
| 'Z': 1 | ||
| } | ||
|
|
||
| LETTER_SCORE = { |
| while len(letters) < 10: | ||
| random_letter = random.choice(string.ascii_uppercase) | ||
| if letters.count(random_letter) >= LETTER_POOL[random_letter]: | ||
| continue | ||
| else: | ||
| letters.append(random_letter) |
There was a problem hiding this comment.
interesting approach! I think it would be more efficient if we got rid of the continue since it isn't doing anything for the code, so maybe do something like this:
| while len(letters) < 10: | |
| random_letter = random.choice(string.ascii_uppercase) | |
| if letters.count(random_letter) >= LETTER_POOL[random_letter]: | |
| continue | |
| else: | |
| letters.append(random_letter) | |
| while len(letters) < 10: | |
| random_letter = random.choice(string.ascii_uppercase) | |
| if letters.count(random_letter) < LETTER_POOL[random_letter]: | |
| letters.append(random_letter) |
| pass | ||
| letters = [] | ||
| while len(letters) < 10: | ||
| random_letter = random.choice(string.ascii_uppercase) |
There was a problem hiding this comment.
instead of bringing another library, let's use what we already have! Maybe we can turn our LETTER_POOL into a list and randomly choose one of the keys:
| random_letter = random.choice(string.ascii_uppercase) | |
| random_letter = random.choice(list(LETTER_POOL)) |
| return letters | ||
|
|
||
|
|
||
| def uses_available_letters(word, letter_bank): |
There was a problem hiding this comment.
👍 wow short and sweet! nicely done
| def score_word(word): | ||
| pass | ||
| score = 0 | ||
| for letter in word.upper(): |
There was a problem hiding this comment.
good idea making sure that the letters and inputs will always be capitalized
| pass No newline at end of file | ||
| max_score = 0 | ||
| for word in word_list: | ||
| score = score_word(word) |
| elif score == max_score: | ||
| max_score_word_list.append(word) | ||
|
|
||
| winner = select_winner(max_score_word_list) |
| return winner, max_score | ||
|
|
||
|
|
||
| def select_winner(word_list): |
No description provided.