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

Spruce- Asli A. and Ivette F. #51

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open

Conversation

IvetteDF
Copy link

No description provided.

Copy link
Collaborator

@audreyandoy audreyandoy left a comment

Choose a reason for hiding this comment

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

Great work Alf and Ivette!

Your submission covers all the learning goals and passes all the tests! Overall, the code was very clean and easy to read. This project is definitely worthy of a green grade 🟢 🌲✨

I added comments and compliments primarily on neat solutions and ways to refactor. My main feedback is to be cautious of creating separate iterations through the same collection. This creates more steps to execute, resulting in a slower-performing program. Conditionals are our best friends for checking data values, don't be afraid to combine them. More friends the better in this case 😄

Keep up the great work 🌲 ✨

'Y': 2,
'Z': 1
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

Great use of constant variables, especially outside of functions. These variables could live inside of functions but they definitely add more clutter to the function body than necessary.

Having constant variables or any other data containing large chunks allows the function body to focus on the important logic (aka the purpose of the function).

Comment on lines +32 to +40
SCORE_CHART = {
1: ['a', 'e', 'i', 'o', 'u', 'l', 'n', 'r', 's', 't'],
2: ['d', 'g'],
3: ['b', 'c', 'm', 'p'],
4: ['f', 'h', 'v', 'w', 'y'],
5: ['k'],
8: ['j', 'x'],
10: ['q', 'z'],
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Love how y'all used the score as the key in this dictionary, very clever!

letter_hand = []
letter_pool_list = []
for letter, number in LETTER_POOL.items():
letter_pool_list.extend([letter] * number)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Great use of extend to create a list of letters according to their letter count in the LETTER_POOL. You can omit the brackets around letter as well and it will create that same single-dimension list. Was the intention to create a nested list?

Suggested change
letter_pool_list.extend([letter] * number)
letter_pool_list.extend(letter * number)


def uses_available_letters(word, letter_bank):
pass
word_checker = letter_bank.copy()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Good job making a copy to avoid the side-effects of altering the letter bank!

num_points += score
if len(word) >= 7:
num_points += 8
return num_points
Copy link
Collaborator

Choose a reason for hiding this comment

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

This function is so clean due to how the points and letters were stored in SCORE_CHART. Great work!!

Comment on lines +84 to +86
score = score_word(word)
words_and_scores.append((word, score))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Great use of the score_word function and storing tuples in a list!

Comment on lines +88 to +96
for pair in words_and_scores:
if pair[1] > highest_score:
highest_score = pair[1]

high_score_words = []
for pair in words_and_scores:
if pair[1] == highest_score:
high_score_words.append(pair)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Instead of making two separate loops to iterate through the same collection, we can combine the logic into one! Doing so will reduce the number of total iterations the algorithm would execute, resulting in a (slightly) faster algorithm.

Generally, if we have to iterate through the same collection multiple times, we might as well try to find a way to combine the logic (in this case conditionals) into a single loop. Kind of like grabbing all the groceries from your car at once rather than going back and doing multiple trips 🤣 , it saves you time!

This will require one additional line of reassigning high_score_words into creating a list with a new pair containing the highest score.

Suggested change
highest_score = 0
for pair in words_and_scores:
if pair[1] > highest_score:
highest_score = pair[1]
high_score_words = []
for pair in words_and_scores:
if pair[1] == highest_score:
high_score_words.append(pair)
highest_score = 0
high_score_words = []
for pair in words_and_scores:
if pair[1] > highest_score:
highest_score = pair[1]
high_score_words = [pair]
elif pair[1] == highest_score:
high_score_words.append(pair)

Comment on lines +100 to +111
if len(pair[0]) == 10:
return pair

shortest_length = 10
for pair in high_score_words:
if len(pair[0]) < shortest_length:
shortest_length = len(pair[0])

for pair in high_score_words:
if len(pair[0]) == shortest_length:
return pair
Copy link
Collaborator

Choose a reason for hiding this comment

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

We can reduce this section into one loop as well. However, this would require the pair with the shortest word length to be stored and later reassigned if the next iteration contained a shorter word.

Suggested change
for pair in high_score_words:
if len(pair[0]) == 10:
return pair
shortest_length = 10
for pair in high_score_words:
if len(pair[0]) < shortest_length:
shortest_length = len(pair[0])
for pair in high_score_words:
if len(pair[0]) == shortest_length:
return pair
shortest_length = 10
shortest_pair = ()
for pair in high_score_words:
if len(pair[0]) == 10:
return pair
elif len(pair[0]) < shortest_length:
shortest_length = len(pair[0])
shortest_pair = pair
elif len(pair[0]) == shortest_length:
return pair
return shortest_pair


def score_word(word):
pass
word = word.lower()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nitpick/Opinion/🧅: If you can keep letter cases and data types consistent throughout a program then absolutely try to! Storing capital letters in SCORE_CHART would have eliminated the need for this line.

However, this is good forecasting for working with APIs/external sources of data. Oftentimes, the data we retrieve from other sources are not in the data structure we expect resulting in transforming the data into the correct letter case or data type for our program (like y'all did here).

Comment on lines +48 to +51
for i in range(10):
letter = random.choice(letter_pool_list)
letter_hand.append(letter)
letter_pool_list.remove(letter)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Good work in adding the remove method to ensure that the letters being picked are valid!

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.

3 participants