-
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
Cheetahs - Emma and Alyssa #70
base: master
Are you sure you want to change the base?
Changes from all commits
f7ab49b
fabc15e
7da8657
b68a118
b8a0ef7
2753382
489c315
98cac41
b5b8c37
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 |
---|---|---|
@@ -0,0 +1,57 @@ | ||
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_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, | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,51 @@ | ||
import random | ||
from adagrams.const_dicts import * | ||
|
||
def draw_letters(): | ||
pass | ||
letter_pool_list = [] | ||
for letter, number in LETTER_POOL.items(): | ||
letter_pool_list.extend([letter]*number) | ||
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. Great way to handle the distribution! |
||
hand_list = [] | ||
while len(hand_list) < 10: | ||
random.shuffle(letter_pool_list) | ||
hand_list.append(letter_pool_list.pop()) | ||
Comment on lines
+9
to
+11
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. This works well to generate a list of 10 random letters, but it's doing a lot of extra work. |
||
return hand_list | ||
|
||
def uses_available_letters(word, letter_bank): | ||
pass | ||
word = word.upper() | ||
new_letter_bank = [] | ||
new_letter_bank.extend(letter_bank) | ||
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. 👍 |
||
for letter in word: | ||
if letter in new_letter_bank: | ||
new_letter_bank.remove(letter) | ||
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. Very clean solution! |
||
else: | ||
return False | ||
return True | ||
|
||
|
||
def score_word(word): | ||
pass | ||
word = word.upper() | ||
sum = 0 | ||
if len(word) >= 7: | ||
sum += 8 | ||
for letter in word: | ||
sum += SCORE_CHART_DICT[letter] | ||
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. Great |
||
return sum | ||
|
||
def get_highest_word_score(word_list): | ||
pass | ||
highest_score = 0 | ||
highest_score_word = "" | ||
|
||
for word in word_list: | ||
score = score_word(word) | ||
high_word_length = len(highest_score_word) | ||
word_length = len(word) | ||
if score > highest_score: | ||
highest_score = score | ||
highest_score_word = word | ||
elif score == highest_score: | ||
if high_word_length == 10 and word_length < high_word_length or word_length == high_word_length: | ||
continue | ||
elif word_length < high_word_length or word_length == 10: | ||
highest_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. Fantastic solution! |
||
return (highest_score_word, highest_score) |
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.
Great!