forked from AdaGold/adagrams-py
-
Notifications
You must be signed in to change notification settings - Fork 135
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
Sapphire-Niambi #123
Open
Lemmi-C
wants to merge
5
commits into
Ada-C19:main
Choose a base branch
from
Lemmi-C:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Sapphire-Niambi #123
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
eb3cc9d
Created an empty list for wave-1 hand
Lemmi-C 1ec75e6
Created a list of letters for the hand (test)
Lemmi-C a141eb5
Random Array
Lemmi-C 44c13eb
Changes to wave 2 and wave 3
Lemmi-C 7076dff
updated letter pool to pass remaining wave 1 test, updated score word…
Lemmi-C File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,131 @@ | ||
import random | ||
import string | ||
|
||
letter_score_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, | ||
} | ||
|
||
letter_pool = ["A", "A", "A", "A", "A", "A", "A", "A", "A", | ||
"B", "B", | ||
"C", "C", | ||
"D", "D", "D", "D", | ||
"E", "E", "E", "E", "E", "E", "E", "E", "E", "E", "E", "E", | ||
"F", "F", | ||
"G", "G", "G", | ||
"H", "H", | ||
"I", "I", "I", "I", "I", "I", "I", "I", "I", | ||
"J", | ||
"K", | ||
"L", "L", "L", "L", | ||
"M", "M", | ||
"N", "N", "N", "N", "N", "N", | ||
"O", "O", "O", "O", "O", "O", "O", "O", | ||
"P", "P", | ||
"Q", | ||
"R", "R", "R", "R", "R", "R", | ||
"S", "S", "S", "S", | ||
"T", "T", "T", "T", "T", "T", | ||
"U", "U", "U", "U", | ||
"V", "V", | ||
"W", "W", | ||
"X", | ||
"Y", "Y", | ||
"Z" | ||
] | ||
|
||
|
||
def draw_letters(): | ||
pass | ||
random.shuffle(letter_pool) | ||
|
||
# Take the first 10 letters from the shuffled pool | ||
letters = letter_pool[:10] | ||
|
||
return letters | ||
|
||
def uses_available_letters(word, letter_bank): | ||
pass | ||
letter_dict = {} | ||
word_dict = {} | ||
|
||
for item in letter_bank: | ||
if (item in letter_dict): | ||
letter_dict[item] += 1 | ||
else: | ||
letter_dict[item] = 1 | ||
|
||
def score_word(word): | ||
pass | ||
for elem in word.upper(): | ||
if (elem in word_dict): | ||
word_dict[elem] += 1 | ||
else: | ||
word_dict[elem] = 1 | ||
|
||
|
||
#returns false if any submitted letters in letter_bank are incorrect | ||
|
||
for key, value in word_dict.items(): | ||
if key not in letter_dict or not value <= letter_dict[key]: | ||
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. Looks like you're failing all the tests for this function. |
||
letter_score_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 | ||
} | ||
# dict that holds the key value pairs of letters and their scores. | ||
#variable that scores will be added to | ||
score_total = 0 | ||
# variable to keep track of the length of each word | ||
#for each letter in the word: | ||
for char in word.upper(): | ||
score_total += letter_score_dict[char] | ||
|
||
if 7 <= len(word) <= 10: | ||
score_total += 8 | ||
return score_total | ||
|
||
def get_highest_word_score(word_list): | ||
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. Looks like you still have more work to do for this function! |
||
pass | ||
best_word = "" | ||
max_score = 0 | ||
|
||
for word in word_list: | ||
score = score_word(word) | ||
|
||
if score > max_score: | ||
best_word = word | ||
max_score = score | ||
elif score == max_score: | ||
if len(best_word) != 10 and len(word) != 10: | ||
if len(word) < len(best_word) or len(best_word) == 10: | ||
best_word = word | ||
elif len(best_word) != 10 and len(word) == 10: | ||
best_word = word | ||
|
||
return (best_word, max_score) | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
👍