Conversation
There was a problem hiding this comment.
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 | ||
| ''' |
| return array_of_letters | ||
| ''' | ||
| array_of_letters = [] | ||
| our_pool = copy.deepcopy(OUR_POOL) |
There was a problem hiding this comment.
Hmm, since you made a deep copy of LETTER_POOL already, what is your thought process on creating a third copy here?
There was a problem hiding this comment.
Agreed, should clean our code!
|
|
||
| #Wave 2 (Bahareh) | ||
| def uses_available_letters(word,letter_bank): | ||
| copied_word=copy.deepcopy(word).upper() |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Oh I like this ternary operator! Very cool!
| # 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) |
There was a problem hiding this comment.
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]) |
| 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] |
There was a problem hiding this comment.
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!
No description provided.