-
Notifications
You must be signed in to change notification settings - Fork 69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Amber Tanaka: Orca Whale #54
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome job! This project is a verdant green. You've got some great compact code here. Nicely done~
'Y': 2, | ||
'Z': 1 | ||
} | ||
LETTER_POINTS = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice use of consts!
while len(chosen_letters) < 10: | ||
random_letter = random.choice(list(letter_pool)) | ||
if letter_pool[random_letter] > 0: | ||
chosen_letters.append(random_letter) | ||
letter_pool[random_letter] -= 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very clever! One small improvement: the call to list
repeatedly transforms the keys of the dictionary into a list. By putting this outside the loop and assigning it to a variable we can reduce some duplicated effort.
def uses_available_letters(word, letter_bank): | ||
pass | ||
letter_bank_copy = copy.deepcopy(letter_bank) | ||
new_word = word.upper() | ||
for letter in new_word: | ||
if letter not in letter_bank_copy: | ||
return False | ||
else: | ||
letter_bank_copy.remove(letter) | ||
return True |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice compact and clean!
def score_word(word): | ||
pass | ||
points = 0 | ||
cased_word = word.upper() | ||
if len(cased_word) >= 7: | ||
points += 8 | ||
for letter in cased_word: | ||
points += LETTER_POINTS[letter] | ||
|
||
return points |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gorgeous!
if score_word(word) > champ_list[1]: | ||
champ_list[0] = word | ||
champ_list[1] = score_word(word) | ||
elif score_word(word) == champ_list[1] and len(word) < len(champ_list[0]) and len(champ_list[0]) != 10: | ||
champ_list[0] = word | ||
champ_list[1] = score_word(word) | ||
elif score_word(word) == champ_list[1] and len(word) == 10 and len(champ_list[0]) != 10: | ||
champ_list[0] = word | ||
champ_list[1] = score_word(word) | ||
return champ_list |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This works great! As an extra exercise, can you consider how you might write this differently by nesting some of your conditional blocks? Do you think this would make it more or less readable? There's no right answer here, it's subjective!
No description provided.