Skip to content

Phoenix - Dana Delgado#43

Open
dmdelg wants to merge 2 commits into
Ada-C22:mainfrom
dmdelg:main
Open

Phoenix - Dana Delgado#43
dmdelg wants to merge 2 commits into
Ada-C22:mainfrom
dmdelg:main

Conversation

@dmdelg

@dmdelg dmdelg commented Sep 20, 2024

Copy link
Copy Markdown

No description provided.

@apradoada apradoada 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.

GREEN!

Well done, Dana! Your code passes all the tests and it looks great! You should be super proud of completing your first Ada project! None of the suggestions I left are required, but you are welcome to implement them if you'd like! If you have any questions, don't hesitate to reach out!

Comment thread adagrams/game.py
letter_list = []

# Go through each letter and its quantities in the letter pool
for letter, quantity in LETTER_POOL.items():

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 with taking the distribution of letters into account! Great use of the extend method! This is short, sweet and concise and works really well!

Comment thread adagrams/game.py
letter_list.pop(index)

# Return the 10 drawn letters
return hand_of_ten_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.

Great job on this function! Everything looks great, and it works really well! The one thing to note is that you include a comment before pretty much every line of code. While this is great for understanding your code, it can start to busy things up. I would recommend either placing the comments in a docstring at the beginning of the function as a quick write up of how the function/ algorithm works or as comments to kick off chunks of code rather than before each line!

Comment thread adagrams/game.py

# Covert all letters to uppercase
word = word.upper()
letter_bank = [letter.upper() for letter in letter_bank]

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 list comprehension!

Comment thread adagrams/game.py

# Create an empty dictionary to count the letters in the letter bank
available_letters = {}
for letter in letter_bank:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

One small thing to think about is that you are creating a dictionary holding all the available letters along with their count. You are creating that dictionary from the letter bank list that you so beautifully created using a list comprehension. My thought here though is that you are not destroying the list you've created in any way, just using the values. Therefore, the list comprehension on line 60 becomes redundant and adds a for loop that doesn't need to exist. We could simply run the letter.upper() on each letter in this for loop and add it to the dictionary rather than include a whole new list comprehension! If we were instead using that comprehension to copy over the letter_bank and then destroying it later on, I could see a use, but for now it just adds an extra for loop!

Comment thread adagrams/game.py
if letter in available_letters and available_letters[letter] > 0:
available_letters[letter] -= 1
else:
return False

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Given what you've got, this for loop looks great!

Comment thread adagrams/game.py
pass

# Create a dictionary based on the score chart
letter_values = {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

When we've got a hard coded dictionary like this, its usually better served as a global variable! Especially if that dictionary was needed for other functions in an expanded version of this project!

Comment thread adagrams/game.py
total_score += letter_values[letter]

# Add bonus pointsif the world lenght is equal or greater to 7
if len(word) >=7:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Small thing, but we have one other constraint on the length of the word! It can't go over 10 letters! If you want to, see if you can add that constraint to this condition!

Comment thread adagrams/game.py
elif len(word) < len(highest_word) and len(highest_word) <10:
highest_word = word
# If both are the same lenght, choose the one that shows first in the list
elif len(word) == len(highest_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.

The only thing this condition does is continue on to the next iteration of the for loop. Since this is the last condition that would be checked before the loop moves to its next iteration, it actually isn't needed! It should work the same way with or without it!

Comment thread adagrams/game.py
# Do nothing and keep the current highest word
continue

return (highest_word, highest_score) No newline at end of file

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Small not, but when we're returning a tuple like this, we actually don't need the parentheses! You are more than welcome to put them in if you'd like but the code will work the same way even if they aren't present!

Comment thread adagrams/game.py
# Get the score of the current word
score = score_word(word)

# If this score is higher than what we've got

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This function and all the logic that goes along with it looks great! I love the way you only focused on words that were of equal or greater value and anything else was ignored! As mentioned before, the one change I would make is to watch your comments! While helpful in the early stages of programming, comments before every line aren't the norm in most work places, so feel free to get in the habit of trying to limit your comments to code blocks or a docstring!

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