-
Notifications
You must be signed in to change notification settings - Fork 57
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
Cedar - Rae and Laurel #33
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.
Nice work! It's great that you used this opportunity to explore OOP and refactor. Great work using a branch for this refactored work. Your code is clear and logical. I've left a few inlines comments on ways you might consider refactoring, but overall, great work!
if remaining_letters_count >= 10: | ||
# do this 10 times: |
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.
Consider whether these if
is necessary. I supposed if we had less than 10 letters in the LETTER_POOL
this would help us avoid an index error, but we may want to deal with that edge case in a different way such as
if len(LETTER_POOL) < 10:
return "LETTER_POOL is too small"
or maybe not -- just something to consider :)
# add letter to list | ||
chosen_letters.append(drawn_letter[0]) | ||
# decrease letter pool count by 1 | ||
LETTER_POOL[drawn_letter[0]] -= 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.
We should make a copy of the LETTER_POOL
so that our function does not directly modify this constant.
if not isinstance(word, str) and len(word) <= 10: | ||
return False | ||
# if word is valid | ||
for char in word.upper(): |
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.
Clear, logical code!
pass | ||
# checks to make sure that word is composed of elements in letter_bank | ||
letter_bank_copy = letter_bank[:] | ||
if not isinstance(word, str) and len(word) <= 10: |
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.
I am not quite sure what this check is doing. A comment to explain this validation check would enhance readability.
high_score_words = [word for word in list_of_word_objects if word.score == high_score] | ||
if len(high_score_words) > 1: | ||
return tie_breaker(high_score_words, high_score) |
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.
Great work encapsulating this functionality in a helper function.
return word.word, score | ||
# otherwise return shortest word | ||
winning_word = min(word_list, key= lambda w: w.length) |
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!
high_score_words = [word for word in list_of_word_objects if word.score == high_score] |
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.
Clever and concise!
Project submission