-
Notifications
You must be signed in to change notification settings - Fork 69
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
Amber Tanaka: Orca Whale #54
base: master
Are you sure you want to change the base?
Changes from all commits
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,111 @@ | ||
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 | ||
} | ||
LETTER_POINTS = { | ||
'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 | ||
} | ||
##----------- WAVE 1 ----------- ## | ||
def draw_letters(): | ||
pass | ||
letter_pool = copy.deepcopy(LETTER_POOL) | ||
chosen_letters = [] | ||
while len(chosen_letters) < 10: | ||
random_letter = random.choice(list(letter_pool)) | ||
if letter_pool[random_letter] > 0: | ||
chosen_letters.append(random_letter) | ||
letter_pool[random_letter] -= 1 | ||
Comment on lines
+63
to
+67
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 clever! One small improvement: the call to |
||
return chosen_letters | ||
|
||
|
||
##----------- WAVE 2 ----------- ## | ||
def uses_available_letters(word, letter_bank): | ||
pass | ||
letter_bank_copy = copy.deepcopy(letter_bank) | ||
new_word = word.upper() | ||
for letter in new_word: | ||
if letter not in letter_bank_copy: | ||
return False | ||
else: | ||
letter_bank_copy.remove(letter) | ||
return True | ||
Comment on lines
72
to
+80
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 compact and clean! |
||
|
||
##----------- WAVE 3 ----------- ## | ||
def score_word(word): | ||
pass | ||
points = 0 | ||
cased_word = word.upper() | ||
if len(cased_word) >= 7: | ||
points += 8 | ||
for letter in cased_word: | ||
points += LETTER_POINTS[letter] | ||
|
||
return points | ||
Comment on lines
83
to
+91
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. Gorgeous! |
||
|
||
##----------- WAVE 4 ----------- ## | ||
def get_highest_word_score(word_list): | ||
pass | ||
champ_list = [] | ||
best_word = word_list[0] | ||
high_score = score_word(best_word) | ||
champ_list.append(best_word) | ||
champ_list.append(high_score) | ||
for word in word_list: | ||
if score_word(word) > champ_list[1]: | ||
champ_list[0] = word | ||
champ_list[1] = score_word(word) | ||
elif score_word(word) == champ_list[1] and len(word) < len(champ_list[0]) and len(champ_list[0]) != 10: | ||
champ_list[0] = word | ||
champ_list[1] = score_word(word) | ||
elif score_word(word) == champ_list[1] and len(word) == 10 and len(champ_list[0]) != 10: | ||
champ_list[0] = word | ||
champ_list[1] = score_word(word) | ||
return champ_list | ||
Comment on lines
+100
to
+110
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 great! As an extra exercise, can you consider how you might write this differently by nesting some of your conditional blocks? Do you think this would make it more or less readable? There's no right answer here, it's subjective! |
||
|
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 consts!