-
Notifications
You must be signed in to change notification settings - Fork 89
Snow Leopards - Irene Cho #75
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?
Changes from all commits
3da0721
7ff73c4
17d1699
a90ff7d
9e8d45b
cfa4b20
550ab78
29e1b08
a96c1e5
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,120 @@ | ||
| 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 draw_letters(): | ||
| pass | ||
| letter_list = [] | ||
| hand = [] | ||
|
|
||
| for letter in LETTER_POOL.keys(): | ||
| for num in range(LETTER_POOL[letter]): | ||
| letter_list.append(letter) | ||
|
|
||
| for draw in range(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. Good job with this one! Since |
||
| index = random.randint(0, (len(letter_list) -1)) | ||
| hand.append(letter_list[index]) | ||
| letter_list.pop(index) | ||
|
|
||
| return hand | ||
|
|
||
| def uses_available_letters(word, letter_bank): | ||
| pass | ||
| try: | ||
| formatted_word = word.upper() | ||
| except AttributeError: | ||
|
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. Good job handling a case where, I believe, the parameter |
||
| return False | ||
|
|
||
| for letter in formatted_word: | ||
| if formatted_word.count(letter) > letter_bank.count(letter): | ||
| return False | ||
| return True | ||
|
|
||
| def score_word(word): | ||
| pass | ||
| formatted_word = word.upper() | ||
| score = 0 | ||
|
|
||
| for letter in formatted_word: | ||
| score += SCORE_CHART[letter] | ||
|
|
||
| if len(word) >= 7: | ||
|
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 with this function! 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. Per the README, the 8 bonus points should be awarded when a word is 7, 8, 9, or 10 letters long so we'll also want to have a check that the length of the word is < 11. |
||
| score += 8 | ||
|
|
||
| return score | ||
|
|
||
| def get_highest_word_score(word_list): | ||
| pass | ||
| winning_word = word_list[0] | ||
| winning_score = score_word(winning_word) | ||
|
|
||
| for word in word_list: | ||
| current_score = score_word(word) | ||
| if current_score > winning_score: | ||
| winning_word = word | ||
| winning_score = current_score | ||
| elif current_score == winning_score: | ||
| winning_word = tie_breaker(winning_word, word) | ||
| winning_score = score_word(winning_word) | ||
|
|
||
| return (winning_word, winning_score) | ||
|
|
||
| def tie_breaker(first, second): | ||
| for word in [first, second]: | ||
| if len(word) == 10: | ||
| return word | ||
| if len(first) < len(second): | ||
|
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. Good job handling the tie cases! |
||
| return first | ||
| elif len(second) < len(first): | ||
| return second | ||
| return first | ||
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.
In Python, looping over a dictionary this way uses its keys by default, so no need to call .
keys(), you can just write