-
Notifications
You must be signed in to change notification settings - Fork 135
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
Sapphire- Janice N. #115
base: main
Are you sure you want to change the base?
Sapphire- Janice N. #115
Changes from all commits
24532de
e9a6ba1
4d42889
96f110e
d1bbdf5
e46c2d8
18f68a5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,128 @@ | ||
import random | ||
|
||
def draw_letters(): | ||
pass | ||
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 | ||
} | ||
list_letter_pool =[] | ||
for letter, number in LETTER_POOL.items(): | ||
letter_quantity = letter * number | ||
list_letter_pool.append(letter_quantity) | ||
|
||
|
||
letter_string = ''.join(list_letter_pool) | ||
|
||
# Available letters with frequencies list | ||
available_letters = list(letter_string) | ||
Comment on lines
+32
to
+41
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In this function, it looks like you're building a list of lists in I think it might be worth thinking about how to refactor this logic-- while we iterate through |
||
|
||
hand = [] | ||
|
||
# Returns a list of 10 random letters | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [nit] This comment should be indented correctly |
||
while len(hand) != 10: | ||
random_letter = random.choice(available_letters) | ||
hand.append(random_letter) | ||
for letter in available_letters: | ||
if letter in hand: | ||
available_letters.remove(letter) | ||
Comment on lines
+46
to
+51
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Your logic ends up being a little bit buggy! I noticed this because when I ran your tests (I run them like 50 times as I grade lol), sometimes 5 tests failed, sometimes 6 tests failed for me. I spent some time trying to learn about the bug and this is what I found. While Your code currently does something else. While The key difference is when you add to This is a fun bug to fix and an interesting refactoring of your code! Let me know what questions come up. |
||
return hand | ||
|
||
def uses_available_letters(word, letter_bank): | ||
pass | ||
|
||
|
||
def uses_available_letters(word, hand): | ||
# Changes user's input to uppercase | ||
word = word.upper() | ||
# Returns true if all the letters in word are in the hand | ||
for letter in word: | ||
if letter in hand and word.count(letter) < hand.count(letter): | ||
continue | ||
elif letter not in hand or word.count(letter) > hand.count(letter): | ||
return False | ||
Comment on lines
+60
to
+64
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good use of for letter in word:
if letter not in hand or word.count(letter) > hand.count(letter):
return False |
||
return True | ||
|
||
|
||
def score_word(word): | ||
pass | ||
|
||
score = 0 | ||
bonus_point_list =[7,8,9,10] | ||
|
||
points_value = {'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 | ||
} # Gets the score of the word | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [nit] This ending brace should be indented, and it might make sense to put the comment on its own line. |
||
for letter in word.upper(): | ||
score += points_value[letter] | ||
if len(word) == 0: | ||
score = 0 | ||
if len(word) in bonus_point_list: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I actually really like how you made and used |
||
score = score + 8 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Small suggestion: |
||
return(score) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [nit] I think it would be better and more consistent code style to |
||
|
||
|
||
def get_highest_word_score(word_list): | ||
pass | ||
# Stores the word and it's score | ||
word_value_dictionary = {} | ||
|
||
# Stores the scores of the words in | ||
score_list = [] | ||
# Scores each word in the word list and stores it a dictionary | ||
for word in word_list: | ||
score = score_word(word) | ||
word_value_dictionary[word] = score | ||
# Gets the highest score | ||
highest_score = max(word_value_dictionary.values()) | ||
# Gets the word with the highest score and returns it in a tuple | ||
for word,value in word_value_dictionary.items(): | ||
if value == highest_score: | ||
score_list.append(word) | ||
score_list.append(highest_score) | ||
|
||
return tuple(score_list) | ||
Comment on lines
+122
to
+127
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice work! It seems like the details about the tie-breaking is what's next in this project. From what I can tell, I think that your next step here could be:
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice use of
join
to flatten/combine the string!