Skip to content

Adagrams Gabriela and Gricelda#46

Open
GitHub4Gigi wants to merge 9 commits intoada-c17:masterfrom
gibarra2:master
Open

Adagrams Gabriela and Gricelda#46
GitHub4Gigi wants to merge 9 commits intoada-c17:masterfrom
gibarra2:master

Conversation

@GitHub4Gigi
Copy link
Copy Markdown

@GitHub4Gigi GitHub4Gigi commented Apr 1, 2022

Gabriela and Gricelda finished Adagrams!

@GitHub4Gigi GitHub4Gigi changed the title Finished Wave 2 and Wave 4 Adagrams Gabriela and Gricelda Apr 1, 2022
Copy link
Copy Markdown

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

Nicely done, Gricelda and Gabriela! There was only a few places I saw that I gave feedback on. Mainly just how to shorten up your code a little.

Good job!!

Comment thread adagrams/game.py
}


def get_letter_frequency(letter_dict, letter):
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 idea for a helper function! One thing I will say, LETTER_POOL already has a frequency for you, which you can reference immediately instead of making a new one.

Comment thread adagrams/game.py
Comment on lines +81 to +92
letters_count = {}
letters = list(LETTER_POOL.keys())

while len(hand) < 10:
random_letter = random.choice(letters)
letters_count = get_letter_frequency(letters_count, random_letter)
letter_limit = LETTER_POOL[random_letter]

if letters_count[random_letter] > letter_limit:
continue

hand.append(random_letter)
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 works fine! But I think we can save a little time by using the LETTER_POOL directly or by making a copy. And remember, if we take a letter away, then we need to subtract it from our pool of letters.

Suggested change
letters_count = {}
letters = list(LETTER_POOL.keys())
while len(hand) < 10:
random_letter = random.choice(letters)
letters_count = get_letter_frequency(letters_count, random_letter)
letter_limit = LETTER_POOL[random_letter]
if letters_count[random_letter] > letter_limit:
continue
hand.append(random_letter)
letters = copy.deepcopy(LETTER_POOL)
while len(hand) < 10:
random_letter = random.choice(letters.keys())
if letters[random_letter] > 0:
hand.append(random_letter)
letters[random_letter] -= 1

Comment thread adagrams/game.py
Comment on lines +115 to +116
else:
continue
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

since this isn't doing anything for us, we can just remove it.

Suggested change
else:
continue

Comment thread adagrams/game.py
Comment on lines +107 to +108
# print(letter)
# print(letter_bank[letter])
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Remember to get rid of print statements that are for debugging purposes

Suggested change
# print(letter)
# print(letter_bank[letter])

Comment thread adagrams/game.py



def score_word(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.

👍

Comment thread adagrams/game.py
Comment on lines +139 to +140


Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggested change

Comment thread adagrams/game.py
Comment on lines +157 to +160




Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggested change

Comment thread adagrams/game.py
@@ -1,11 +1,163 @@
from operator import truediv
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hmm did you use this? I didn't see it. Let's get rid of it!

Suggested change
from operator import truediv

Comment thread adagrams/game.py
return points


def get_highest_word_score(word_list):
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

👍

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