-
Notifications
You must be signed in to change notification settings - Fork 57
Maple - Jesse P. #49
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
base: master
Are you sure you want to change the base?
Maple - Jesse P. #49
Changes from all commits
2ed08e0
1586a6d
6b2266a
935e08b
3b66424
7c26c51
be82e95
224dd4e
23658ef
a0cf4bd
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,117 @@ | ||||||||||
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 | ||||||||||
} | ||||||||||
|
||||||||||
LETTER_VALUES = { | ||||||||||
'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 | ||||||||||
letters_left = LETTER_POOL.copy() | ||||||||||
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. 👍 glad to see a |
||||||||||
choice_ten = [] | ||||||||||
while len(choice_ten) < 10: | ||||||||||
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 like the while loop! It's six to half a dozen of the other using a for-loop instead, but I think this makes more sense readability-wise |
||||||||||
letter = random.choice(list(letters_left)) | ||||||||||
if letters_left[letter] > 0: | ||||||||||
choice_ten.append(letter) | ||||||||||
letters_left[letter] -= 1 | ||||||||||
return choice_ten | ||||||||||
Comment on lines
+65
to
+69
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. 👍 glad you spotted that you need to check if there are still letters available after randomly selecting a key from |
||||||||||
|
||||||||||
|
||||||||||
Comment on lines
+70
to
+71
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.
Suggested change
|
||||||||||
|
||||||||||
def uses_available_letters(word, letter_bank): | ||||||||||
pass | ||||||||||
def uses_available_letters(word, choice_ten): | ||||||||||
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. 👍 |
||||||||||
letters_in_hand = choice_ten.copy() | ||||||||||
for letter in word: | ||||||||||
if letter in letters_in_hand: | ||||||||||
letters_in_hand.remove(letter) | ||||||||||
else: | ||||||||||
return 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 | ||||||||||
total = 0 | ||||||||||
for letter in word: | ||||||||||
total += LETTER_VALUES[letter.upper()] | ||||||||||
if len(word) >= 7: | ||||||||||
total += 8 | ||||||||||
|
||||||||||
return total | ||||||||||
|
||||||||||
def get_highest_word_score(word_list): | ||||||||||
pass | ||||||||||
top_word = None | ||||||||||
top_score = 0 | ||||||||||
for word in word_list: | ||||||||||
score = score_word(word) | ||||||||||
if score < top_score: | ||||||||||
pass | ||||||||||
elif score > top_score: | ||||||||||
top_word = word | ||||||||||
top_score = score | ||||||||||
elif score == top_score: | ||||||||||
if len(word) == len(top_word): | ||||||||||
pass | ||||||||||
elif len(top_word) == 10: | ||||||||||
pass | ||||||||||
elif len(word) == 10: | ||||||||||
top_word = word | ||||||||||
top_score = score | ||||||||||
elif len(word) < len(top_word): | ||||||||||
top_word = word | ||||||||||
top_score = score | ||||||||||
return top_word, top_score | ||||||||||
Comment on lines
+96
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. while this works great, you can also consider removing any if statements that don't have any actionable commands inside of it, like line 102 and 104. If it's because it's easier to read, awesome! totally valid! you are likely to see these if statements stripped out, though to keep the code drier. 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 tuple return! |
||||||||||
|
||||||||||
|
||||||||||
|
||||||||||
|
||||||||||
Comment on lines
+113
to
+116
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.
Suggested change
|
||||||||||
|
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.
:+1 good job making this a constant variable with all caps