Skip to content
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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Conversation

AmberRose2
Copy link

No description provided.

Copy link

@alope107 alope107 left a 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 = {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice use of consts!

Comment on lines +63 to +67
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
Copy link

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.

Comment on lines 72 to +80
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
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice compact and clean!

Comment on lines 83 to +91
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
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gorgeous!

Comment on lines +100 to +110
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
Copy link

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants