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

Sphinx Class - Denise C. #36

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

dpchengmath
Copy link

No description provided.

Copy link

@yangashley yangashley left a 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!

Let me know if you have questions about my comments!

'X': 8,
'Y': 4,
'Z': 10
}

Choose a reason for hiding this comment

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

Nice job naming LETTER_POOL and LETTER_POINT_VALUES as constant variables 👍

adagrams/game.py Outdated

list_of_all_letters = []

for letter,amount_of_that_letter in LETTER_POOL.items():

Choose a reason for hiding this comment

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

Missing white space after the comma, should look like letter, amount_of_that_letter.

It's a small thing, but as you write more code (and eventually contribute to a large codebase) it's important to be consistent with whitespaces so that the whole project stays neat. Here's the official Python style guide that covers whitespaces.

Choose a reason for hiding this comment

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

amount_of_that_letter is descriptive but might be considered a little lengthy. What about something like letter_freq?

adagrams/game.py Outdated
list_of_all_letters = []

for letter,amount_of_that_letter in LETTER_POOL.items():
for _ in range(amount_of_that_letter):

Choose a reason for hiding this comment

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

👍 good use of _ when we don't need an actual looping variable

adagrams/game.py Outdated

for letter,amount_of_that_letter in LETTER_POOL.items():
for _ in range(amount_of_that_letter):
list_of_all_letters.append(letter)

Choose a reason for hiding this comment

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

How do you think you could use list comprehension to write the loop from lines 66-68 in one line?

adagrams/game.py Outdated
'Y': 4,
'Z': 10
}

def draw_letters():
Copy link

@yangashley yangashley Sep 20, 2024

Choose a reason for hiding this comment

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

Notice that the draw_letters method has two responsibilities. It is creating a letter pool to draw from and then pulling random letters. To keep your methods to a single responsibility, consider pulling out the logic from lines 64-68 into a helper function and then invoking that helper function in draw_letters. Maybe something like create_letter_pool?

adagrams/game.py Outdated
Comment on lines 108 to 109
for letter in word:
letter = letter.upper()

Choose a reason for hiding this comment

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

Same comment as above, call upper on word before looping

adagrams/game.py Outdated

def score_word(word):
pass
sum = 0

Choose a reason for hiding this comment

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

While we are accumulating the score for each letter, a more descriptive name for this variable could be total_score

Comment on lines +124 to +144
def test_get_highest_word_many_ties_pick_first_shortest():
# Arrange
words = ["LL", "NN", "RR", "AA"]

# Act
best_word = get_highest_word_score(words)

# Assert
assert best_word[0] == "LL"
assert best_word[1] == 2

def test_get_highest_word_many_ties_pick_first_shortest_not_in_first_position():
# Arrange
words = ["LL", "NN", "JQ", "AA"]

# Act
best_word = get_highest_word_score(words)

# Assert
assert best_word[0] == "JQ"
assert best_word[1] == 18

Choose a reason for hiding this comment

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

🎉🤗 Nice!

adagrams/game.py Outdated
winning_word_info = [] # ["word", score] index = [0, 1]

Choose a reason for hiding this comment

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

Remove debugging comments when you submit code. It's not a big deal here but when you go to industry, extraneous comments will clutter up huge codebases. Since your code is self-documenting with descriptively named variables and functions and is readable, we wouldn't need this comment to understand how the code works.

adagrams/game.py Outdated
Comment on lines 132 to 134

return winning_word_info_tuple

Choose a reason for hiding this comment

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

Instead of creating a list winning_word_info and then casting that list to a tuple, you can directly return a tuple like this:

return word, word_score

With this refactor you'd have to update the loop a little bit so you know the word_score and the word that corresponds to it.

Recall that tuple syntax can omit parens and just use commas to separate the elements of a tuple:
image

https://learn-2.galvanize.com/cohorts/4211/blocks/1032/content_files/representing-data/tuples.md

Comment on lines +106 to +109
for letter in word.upper():
total_score += LETTER_POINT_VALUES[letter]
if len(word) >= 7:
total_score += 8
Copy link

@yangashley yangashley Sep 23, 2024

Choose a reason for hiding this comment

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

Didn't call this out earlier, but your code would be more self-documenting by using constant variables here too:

    BONUS_LENGTH_MIN = 7
    BONUS_POINTS = 8

Copy link

@yangashley yangashley Sep 23, 2024

Choose a reason for hiding this comment

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

While a hand can't be more than 10 letters and therefore a word can't be more than 10 letters, you could make this check more explicit and conform to the instructions in the README more by having the check on line 108 be: if BONUS_LENGTH_MIN <= len(word) <= BONUS_LENGTH_MAX:

Where BONUS_LENGTH_MAX is 10

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