-
Notifications
You must be signed in to change notification settings - Fork 50
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
Sunitha N -Adagrams-ADA-C22-Sphinx #46
base: main
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.
Great job on Adagrams!
In the future, consider making a commit after finishing each wave.
Let me know if you have questions about my comments!
@@ -1,11 +1,150 @@ | |||
import random |
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.
Usually we leave a blank line after imports
You can review the official Python style guide about blank line conventions.
adagrams/game.py
Outdated
def draw_letters(): | ||
pass | ||
letter_pool = { |
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.
letter_pool
is a constant variable and should be named with capital letters like LETTER_POOL
adagrams/game.py
Outdated
|
||
total_letters = sum(letter_pool.values()) | ||
|
||
while len(drawn_letters) < 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'd like to see the literal integer 10
referenced by a constant variable. As someone who might not know anything about this game, I might read line 49 and wonder what the significance of 10 means.
How about something like:
HAND_SIZE = 10
while len(drawn_letters) < HAND_SIZE:
adagrams/game.py
Outdated
|
||
while len(drawn_letters) < 10: | ||
# Generating a random number between 1 and the total number of letters | ||
rand_num = random.randint(1, total_letters) |
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.
While randint()
does return a random number, rand_num
doesn't quite describe what this random integer represents in our game. A name like rand_index
is a little more descriptive.
letter_pool[letter] -= 1 | ||
total_letters -= 1 | ||
break | ||
|
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 think one blank line after break
is ok to help separate the logical parts of this function, but having 2 is not needed. Line 62 can be removed.
adagrams/game.py
Outdated
max_word = word_list[0] | ||
max_word_score =score_word(max_word) |
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.
Missing white space after equal sign
max_word_score =score_word(max_word) | ||
#iterating from the second word | ||
for word in word_list[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.
👍 nice job slicing off the first word since it's already defined as the max_word
on line 132.
adagrams/game.py
Outdated
|
||
max_word_score = max(max_word_score, word_score) | ||
return (max_word,max_word_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.
Missing white space after comma and there's an extra white space that needs to be removed after max_word_score
.
elif word_score == max_word_score: | ||
# Prefer the word with the fewest letters, unless one has 10 letters | ||
if len(word) == 10 and len(max_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.
We could use a constant variable to reference 10, maybe something like TIE_BREAKER_LENGTH = 10
or something else to describe why 10 is significant in this logic.
max_word = word | ||
|
||
max_word_score = max(max_word_score, word_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.
Do we need line 149 when you reassign the value of max_word_score
to be the current highest score on lines 124 - 126?
Creating pull request of Adagrams to review for Sunitha Nela