Skip to content

Maple Ayaka and Grace(Jiajia Wang) #40

Open
wangjiajia95 wants to merge 4 commits intoAda-C16:masterfrom
wangjiajia95:master
Open

Maple Ayaka and Grace(Jiajia Wang) #40
wangjiajia95 wants to merge 4 commits intoAda-C16:masterfrom
wangjiajia95:master

Conversation

@wangjiajia95
Copy link
Copy Markdown

No description provided.

@wangjiajia95 wangjiajia95 changed the title Maple Grace(Jiajia Wang) Maple Ayaka and Grace(Jiajia Wang) Sep 26, 2021
Copy link
Copy Markdown
Collaborator

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

Ayaka and Grace, great job! Your problem solving was very inventive. I liked lines 47 and 48, where you simplified the nested for loop and made it more readable actually! Very nice!

Keep up the great work, you two!

Comment thread adagrams/game.py
'Z': 1
}

LETTER_SCORE = {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

👍 nice idea!

Comment thread adagrams/game.py
Comment on lines +46 to +51
while len(letters) < 10:
random_letter = random.choice(string.ascii_uppercase)
if letters.count(random_letter) >= LETTER_POOL[random_letter]:
continue
else:
letters.append(random_letter)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

interesting approach! I think it would be more efficient if we got rid of the continue since it isn't doing anything for the code, so maybe do something like this:

Suggested change
while len(letters) < 10:
random_letter = random.choice(string.ascii_uppercase)
if letters.count(random_letter) >= LETTER_POOL[random_letter]:
continue
else:
letters.append(random_letter)
while len(letters) < 10:
random_letter = random.choice(string.ascii_uppercase)
if letters.count(random_letter) < LETTER_POOL[random_letter]:
letters.append(random_letter)

Comment thread adagrams/game.py
pass
letters = []
while len(letters) < 10:
random_letter = random.choice(string.ascii_uppercase)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

instead of bringing another library, let's use what we already have! Maybe we can turn our LETTER_POOL into a list and randomly choose one of the keys:

Suggested change
random_letter = random.choice(string.ascii_uppercase)
random_letter = random.choice(list(LETTER_POOL))

Comment thread adagrams/game.py
return letters


def uses_available_letters(word, letter_bank):
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

👍 wow short and sweet! nicely done

Comment thread adagrams/game.py
def score_word(word):
pass
score = 0
for letter in word.upper():
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

good idea making sure that the letters and inputs will always be capitalized

Comment thread adagrams/game.py
pass No newline at end of file
max_score = 0
for word in word_list:
score = score_word(word)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

👍 yay helper functions!

Comment thread adagrams/game.py
elif score == max_score:
max_score_word_list.append(word)

winner = select_winner(max_score_word_list)
Copy link
Copy Markdown
Collaborator

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
return winner, max_score


def select_winner(word_list):
Copy link
Copy Markdown
Collaborator

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