-
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 - Monica Lagdaan #119
base: main
Are you sure you want to change the base?
Changes from all commits
60f55c9
617cfe8
f76f4f6
d101dd8
c532756
0118bb9
0b2ea4d
34491b2
e7dd109
149bdd0
8f74371
09d1a48
722b7b8
e913eab
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,148 @@ | ||
import random | ||
|
||
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 | ||
} | ||
|
||
POINTS_DICT = { | ||
'A': 1, | ||
'B': 3, | ||
'C': 3, | ||
'D': 2, | ||
'E': 1, | ||
'F': 4, | ||
'G': 2, | ||
'H': 4, | ||
'I': 1, | ||
'J': 8, | ||
'K': 5, | ||
'L': 1, | ||
'M': 3, | ||
'N': 1, | ||
'O': 1, | ||
'P': 3, | ||
'Q': 10, | ||
'R': 1, | ||
'S': 1, | ||
'T': 1, | ||
'U': 1, | ||
'V': 4, | ||
'W': 4, | ||
'X': 8, | ||
'Y': 4, | ||
'Z': 10 } | ||
|
||
def draw_letters(): | ||
pass | ||
used_letters = {} | ||
letters_hand = [] | ||
possible_letters = [] | ||
|
||
#creates possible_letters list | ||
for key, value in LETTER_POOL.items(): | ||
for i in range(value): | ||
possible_letters.append(key) | ||
Comment on lines
+66
to
+68
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 creating a list and ensuring it reflects the statistical probability of drawing vowels vs. consonants. |
||
|
||
#pull 10 letters | ||
while len(letters_hand) <= 9: | ||
random_int = random.randint(0,len(possible_letters)- 1) | ||
chosen_letter = possible_letters[random_int] | ||
letters_hand.append(chosen_letter) | ||
possible_letters.remove(chosen_letter) | ||
return letters_hand | ||
Comment on lines
+71
to
+76
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. 👍 |
||
|
||
|
||
def uses_available_letters(word, letter_bank): | ||
pass | ||
upper_word = word.upper() | ||
letter_bank_copy = letter_bank.copy() | ||
|
||
for character in upper_word: | ||
if character not in letter_bank_copy: | ||
return False | ||
else: | ||
letter_bank_copy.remove(character) | ||
return True | ||
Comment on lines
+80
to
+88
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. 👍 |
||
|
||
|
||
def score_word(word): | ||
pass | ||
upper_word = word.upper() | ||
total_points = 0 | ||
|
||
|
||
for character in upper_word: | ||
total_points += POINTS_DICT[character] | ||
|
||
if len(upper_word) >= 7: | ||
total_points += 8 | ||
else: | ||
total_points += 0 | ||
return total_points | ||
Comment on lines
+92
to
+103
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. 👍 |
||
|
||
|
||
|
||
def get_highest_word_score(word_list): | ||
pass | ||
highest_score = 0 | ||
score_dict = {} | ||
winning_word = "" | ||
tie_breaker = {} | ||
|
||
#calculates word & score & adds to score_dict | ||
for word in word_list: | ||
scorez = score_word(word) | ||
score_dict[word] = scorez | ||
|
||
# assigns highest_score & winning_word | ||
for word, scorez in score_dict.items(): | ||
if scorez > highest_score: | ||
highest_score = scorez | ||
winning_word = word | ||
|
||
elif scorez == highest_score: | ||
if len(winning_word) == 10: | ||
pass | ||
elif len(word) == 10: | ||
winning_word = word | ||
elif len(word) < len(winning_word): | ||
winning_word = word | ||
elif len(word) == len(winning_word): | ||
pass | ||
return (winning_word, highest_score) | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
#indexing into a tuple | ||
|
||
# if 2 scorez are the same: | ||
# len of shortest word wins | ||
# elif len(word) == 10 | ||
# that word wins | ||
# elif if len(word) == len(word) and score ==score: | ||
# pick the first occuring | ||
Comment on lines
+135
to
+148
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. Commented out code should be removed from PR's. |
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 work using the uppercase naming convention to indicate that this is a constant variable ✨
Since
LETTER_POOL
is accessed by one function, it would be reasonable to place them inside the functions rather than as a constant. There are tradeoffs, the structures would clutter the function some, but it keeps the data as close as possible to where it's being used, and would mean other functions couldn't access it to accidentally alter the content.