-
Notifications
You must be signed in to change notification settings - Fork 89
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
Tigers - Rose and Kindra #63
base: master
Are you sure you want to change the base?
Changes from all commits
591965a
3f9b3a1
9d34b4f
292c92c
26a9a24
2479827
937fefb
15d4b0c
f23625a
1b536d9
7f00358
d6f393f
5bb7f68
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,113 @@ | ||
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 | ||
} | ||
|
||
SCORE_CHART = { | ||
'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 | ||
} | ||
|
||
def create_letter_pool_list(LETTER_POOL): | ||
letter_pool_list = [] | ||
for key, value in LETTER_POOL.items(): | ||
for i in range(value): | ||
letter_pool_list.append(key) | ||
return letter_pool_list | ||
|
||
def draw_letters(): | ||
pass | ||
hand_of_ten_letters = [] | ||
letter_pool_list = create_letter_pool_list(LETTER_POOL) | ||
while len(hand_of_ten_letters) < 10: | ||
random_letter = random.choice(letter_pool_list) | ||
count = hand_of_ten_letters.count(random_letter) | ||
if count < LETTER_POOL[random_letter]: | ||
Comment on lines
+72
to
+73
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. Since the Now, the next time line 71 executes, it will have an accurate pool of letters that never need recounting. If it's in the list still, then it's fair game. Either works! I don't think my suggestion is any more efficient than yours, however! |
||
hand_of_ten_letters.append(random_letter) | ||
return(hand_of_ten_letters) | ||
|
||
|
||
def uses_available_letters(word, letter_bank): | ||
pass | ||
def uses_available_letters(word, hand_of_ten_letters): | ||
word = word.upper() | ||
for char in word: | ||
if word.count(char) is not hand_of_ten_letters.count(char): | ||
return False | ||
Comment on lines
+81
to
+82
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 job! While the tests all passed, I think we can expand on the logic here to make it more robust. Let's say our word is "DOG" and our hand is [D,G,G,I,O,D,L,A,S,T] Would your function return this as true or false? |
||
return True | ||
|
||
def score_word(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. 👍 |
||
pass | ||
word = word.upper() | ||
score = 0 | ||
for letter in word: | ||
score += (SCORE_CHART[letter]) | ||
if len(word) >= 7: | ||
score += 8 | ||
return(score) | ||
|
||
def get_highest_word_score(word_list): | ||
pass | ||
highest_score = 0 | ||
highest_scoring_word = "" | ||
for word in word_list: | ||
score = score_word(word) | ||
if highest_score < score: | ||
highest_score = score | ||
highest_scoring_word = word | ||
elif highest_score == score: | ||
highest_scoring_word_length = len(highest_scoring_word) | ||
current_word_length = len(word) | ||
if highest_scoring_word_length != current_word_length: | ||
if current_word_length == 10: | ||
highest_scoring_word = word | ||
elif highest_scoring_word_length > current_word_length and highest_scoring_word_length != 10: | ||
highest_scoring_word = word | ||
|
||
highest_score_tuple = highest_scoring_word,highest_score | ||
return(highest_score_tuple) | ||
Comment on lines
+111
to
+112
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. We could combine these together in one line: return highest_scoring_word,highest_score |
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from tests.test_wave_01 import LETTER_POOL | ||
import random | ||
|
||
|
||
def draw_letters(): | ||
#returns: ["a", "b", "c", ...] player's hand | ||
#letter doesn't change | ||
#can't have more than the alloted number of a letter | ||
|
||
#initialize empty list | ||
result_list = [] | ||
#set up dictionary of letter pool | ||
character, frequency = random.choice(list(LETTER_POOL.items())) | ||
print(character, frequency) | ||
|
||
|
||
|
||
#a loop to check if len is under 10 | ||
#if not | ||
#return result_list | ||
draw_letters() |
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.
Love a good helper function!! 👍 By creating a list of all letters by quantity, we get a more accurate hand of letter from the pool!