Skip to content

"Sharks - Bahareh, Anya"#34

Open
AnnnAPr wants to merge 6 commits intoada-c17:masterfrom
AnnnAPr:master
Open

"Sharks - Bahareh, Anya"#34
AnnnAPr wants to merge 6 commits intoada-c17:masterfrom
AnnnAPr:master

Conversation

@AnnnAPr
Copy link

@AnnnAPr AnnnAPr commented Mar 31, 2022

No description provided.

Copy link

@spitsfire spitsfire 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, Bahareh and Anya!! I didn't have much feedback to give. Your code was readable, and it was cool to see how you used ternary operators to save yourself some lines of code. Here is also your refactored code you gave me for checking probability (just to keep all your code together)

def draw_letters():
   each_letter_pool = []
    for letter, freq in LETTER_POOL.items():
        for i in range (freq):
            each_letter_pool.append(letter)
    print(each_letter_pool)
    hand_pool = []
    while len(hand_pool) < 10:
        letter = random.choice(each_letter_pool)
        hand_pool.append(letter)
        each_letter_pool.remove(letter)
    return hand_pool

This is a very readable way to make sure probability is weighed! Nicely done!

#Wave 1
def draw_letters():
pass
'''

Choose a reason for hiding this comment

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

👍 great use of a docstring!

return array_of_letters
'''
array_of_letters = []
our_pool = copy.deepcopy(OUR_POOL)

Choose a reason for hiding this comment

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

Hmm, since you made a deep copy of LETTER_POOL already, what is your thought process on creating a third copy here?

Copy link
Author

@AnnnAPr AnnnAPr Apr 8, 2022

Choose a reason for hiding this comment

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

Agreed, should clean our code!


#Wave 2 (Bahareh)
def uses_available_letters(word,letter_bank):
copied_word=copy.deepcopy(word).upper()

Choose a reason for hiding this comment

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

We don't need to make a deep copy of word. It is immutable, so it won't have side effects.

'''
word1 = word.upper()

score = 8 if len(word1) > 6 else 0

Choose a reason for hiding this comment

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

Oh I like this ternary operator! Very cool!

Comment on lines +147 to +152
# for i in copied_word:
# if i in score_chart:
# result.append(score_chart[i])
# if len(copied_word)==8 or len(copied_word)==9 or len(copied_word)==10 or len(copied_word)==7:
# result.append(8)
# score =sum(result)

Choose a reason for hiding this comment

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

Ohh interesting approach! I would say, since sum has a for loop inside it already, we could just use += so sum up the score manually in the first for loop and save us duplicating data inside result

otherwise return word of minimum length

'''
highest_score = score_word(word_list[0])

Choose a reason for hiding this comment

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

👍 yay helper function!

Comment on lines +178 to +181
ten_len_word = [word for word in list_of_highest_score_words if len(word) == 10]
min_len_word = min((word for word in list_of_highest_score_words if word), key=len)

return [ten_len_word[0], highest_score] if ten_len_word else [min_len_word, highest_score]

Choose a reason for hiding this comment

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

dang very cool yall! The variables are very descriptive, so even though it may not be as easy to read to other coders potentially, it's clear what you are accomplishing!

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