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

AbigailGoodmanC19ATLAdagrams #129

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
104 changes: 100 additions & 4 deletions adagrams/game.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,107 @@

# import random
import random

import copy
LETTER_POOL = {
'A': 9,
'B': 2,
'C': 2,
'D': 4,
'E': 12,
'F': 2,
'G': 3,
'H': 2,
'I': 9,
'J': 1,
'K': 1,
'L': 4,
'M': 2,
'N': 6,
'O': 8,
'P': 2,
'Q': 1,
'R': 6,
'S': 4,
'T': 6,
'U': 4,
'V': 2,
'W': 2,
'X': 1,
'Y': 2,
'Z': 1
}
Comment on lines +6 to +33

Choose a reason for hiding this comment

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

Hi Abby! Great job completing Adagrams! Congrats on your first project at Ada 🎉 Excellent choice with this data structure 💯

letter_list = []
for letter in LETTER_POOL.keys():
letter_list += LETTER_POOL[letter] * letter
# print(letter_list)

Choose a reason for hiding this comment

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

It’s good practice to avoid committing commented out code when submitting a PR.

Choose a reason for hiding this comment

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

A better place for this code would be inside the draw_letters() function since we're only using the letter_list in this function. It should live there 👍🏾


def draw_letters():
pass
selected_letters = []
while len(selected_letters) < 10:
random_index = random.randint(0, len(letter_list)-1)
chosen_letter = letter_list[random_index]
if selected_letters.count(chosen_letter) < LETTER_POOL[chosen_letter]:
selected_letters += chosen_letter
# print(selected_letters)

else:
continue
print(selected_letters)
return selected_letters



Comment on lines +52 to +54

Choose a reason for hiding this comment

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

It’s good practice to avoid committing extra or white space when submitting a PR.


def uses_available_letters(word, letter_bank):
pass
# letter_bank = str(input("please input an anagram "))
# while type(word) == str:
Comment on lines +57 to +58

Choose a reason for hiding this comment

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

Be sure to avoid committing commented out code when submitting a PR.

list_copy = copy.deepcopy(letter_bank)

for character in word.upper():
if character in list_copy:
list_copy.remove(character)
else:
return False


return True
Comment on lines 56 to +68

Choose a reason for hiding this comment

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

👍🏾



def score_word(word):
pass
word_score = 0
scores = {"A" : 1, "E": 1, "I": 1, "O": 1, "U": 1 ,"L": 1, "N": 1, "R": 1, "S": 1, "T": 1, "D": 2, "G": 2,"B": 3, "C": 3, "M": 3, "P": 3, "F": 4, "H": 4, "V": 4, "W": 4, "Y": 4,"K": 5, "J": 8, "X":8 ,"Q": 10, "Z": 10}
Comment on lines +72 to +73

Choose a reason for hiding this comment

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

This is an optimal data structure for the letter scores, outstanding 💫


for letter in word.upper():
word_score += scores[letter]
if len(word) >= 7:
word_score += 8
Comment on lines +77 to +78

Choose a reason for hiding this comment

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

Nice job with the scoring logic 🎉 We can also combine conditionals in one by checking if the length of the word is greater than 6 and less than 11. Refer to your readme for more on this


return word_score




Comment on lines +81 to +84

Choose a reason for hiding this comment

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

It’s good practice to avoid committing extra or white space when submitting a PR.


def get_highest_word_score(word_list):
pass
winning_word = ''

highest_score = 0
for word in word_list:
word_score = score_word(word)
if word_score > highest_score: # if word_score is greater than the highest score

highest_score = word_score
winning_word = word # winning words now contains the winning word
elif word_score == highest_score: # and if word_score is equal to the highest word
if len(winning_word) == 10:
pass
elif len(word) < len(winning_word) and len(winning_word) != 10: # nested conditional, if the length of the word is greater than the chosen word
winning_word = word
elif len(word) == 10 and len(winning_word) != 10:
winning_word = word



return winning_word, highest_score

Loading