Skip to content

Sunitha N -Adagrams-ADA-C22-Sphinx#46

Open
nelasunitha wants to merge 3 commits into
Ada-C22:mainfrom
nelasunitha:main
Open

Sunitha N -Adagrams-ADA-C22-Sphinx#46
nelasunitha wants to merge 3 commits into
Ada-C22:mainfrom
nelasunitha:main

Conversation

@nelasunitha

@nelasunitha nelasunitha commented Sep 20, 2024

Copy link
Copy Markdown

Creating pull request of Adagrams to review for Sunitha Nela

@nelasunitha nelasunitha changed the title Sunitha N -Adagrsms-ADA-C22-Sphinx Sunitha N -Adagrams-ADA-C22-Sphinx Sep 20, 2024

@yangashley yangashley left a comment

Copy link
Copy Markdown

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!

Comment thread adagrams/game.py
@@ -1,11 +1,150 @@
import random

Copy link
Copy Markdown

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.

Comment thread adagrams/game.py Outdated
import random
def draw_letters():
pass
letter_pool = {

Copy link
Copy Markdown

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

Comment thread adagrams/game.py Outdated

total_letters = sum(letter_pool.values())

while len(drawn_letters) < 10:

Copy link
Copy Markdown

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:

Comment thread 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)

Copy link
Copy Markdown

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.

Comment thread adagrams/game.py
letter_pool[letter] -= 1
total_letters -= 1
break

Copy link
Copy Markdown

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.

Comment thread adagrams/game.py Outdated
def get_highest_word_score(word_list):
pass No newline at end of file
max_word = word_list[0]
max_word_score =score_word(max_word)

Copy link
Copy Markdown

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

Comment thread adagrams/game.py
max_word = word_list[0]
max_word_score =score_word(max_word)
#iterating from the second word
for word in word_list[1:]:

Copy link
Copy Markdown

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.

Comment thread adagrams/game.py Outdated
max_word = word

max_word_score = max(max_word_score, word_score)
return (max_word,max_word_score )

Copy link
Copy Markdown

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.

Comment thread adagrams/game.py
# words with same 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:

Copy link
Copy Markdown

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.

Comment thread adagrams/game.py
elif len(word) < len(max_word) and len(max_word) != 10:
max_word = word

max_word_score = max(max_word_score, word_score)

Copy link
Copy Markdown

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?

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