forked from AdaGold/adagrams-py
-
Notifications
You must be signed in to change notification settings - Fork 49
Sphinx - Leidy Martinez #44
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
Open
Leidy-Martinez
wants to merge
7
commits into
Ada-C22:main
Choose a base branch
from
Leidy-Martinez: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
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
3c53904
Finished wave 3
Leidy-Martinez 7460537
All test passed
Leidy-Martinez 53f9800
Add info about func to practice
Leidy-Martinez 566dbd7
Fixed draw_letters func to get frequencies
Leidy-Martinez 3b42cd0
Used Casefold in uses_available_letter func for case matching
Leidy-Martinez 33561ac
Changed second if to elif in get_highest_word_score for resourcing
Leidy-Martinez cb37ffd
modified score word func
Leidy-Martinez 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 hidden or 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,123 @@ | ||
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 | ||
} | ||
|
||
def draw_letters(): | ||
pass | ||
#Create a set of 10 letters that matches the letter frequency distribution# | ||
draw = [] | ||
letter_pool_copy = [] | ||
|
||
#Calculate the weigths for each letter | ||
for letter, frequency in LETTER_POOL.items(): | ||
weights = letter*frequency | ||
#add the weight letters to a new list | ||
for char in weights: | ||
letter_pool_copy.append(char) | ||
|
||
while len(draw) < 10: | ||
#Take a random number within the len of letter pool and get the letter in that index | ||
random_letter = letter_pool_copy[random.randint(0,len(letter_pool_copy)-1)] | ||
|
||
#Check if the letter is still availabe in the letter pool and add it to the hand | ||
if random_letter in letter_pool_copy: | ||
draw.append(random_letter) | ||
|
||
#reduce the frequency in letter pool, for each letter added to the hand | ||
letter_pool_copy.remove(random_letter) | ||
|
||
return draw | ||
|
||
def uses_available_letters(word, letter_bank): | ||
pass | ||
#check if the word is an anagram of some or all of the given letters in the hand | ||
|
||
casefold_word = word.casefold() | ||
letter_bank_copy = [] | ||
|
||
#Ensure letter matching in letter_bank and word | ||
for letter in letter_bank: | ||
letter_bank_copy.append(letter.casefold()) | ||
|
||
for char in casefold_word: | ||
#Take one of the letters from the hand and make unavailable in the bank copy | ||
if char in letter_bank_copy: | ||
letter_bank_copy.remove(char) | ||
else: | ||
return False | ||
|
||
return True | ||
|
||
#-------- Score-Word Func Using Nested Lists --------# | ||
SCORE_DICT = { '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 score_word(word): | ||
pass | ||
score = 0 | ||
|
||
casefold_word = word.casefold() | ||
|
||
for letter in casefold_word: | ||
print (letter) | ||
score += SCORE_DICT.get(letter) | ||
|
||
if len(casefold_word) > 6: | ||
score += 8 | ||
|
||
return score | ||
|
||
def get_highest_word_score(word_list): | ||
pass | ||
#Calculate which word from the list has the highest score | ||
# applying tie-breaking logic | ||
|
||
highest_score = 0 | ||
highest_word = " " | ||
|
||
#calculate score for word in word_list | ||
for word in word_list: | ||
current_score = score_word(word) | ||
|
||
#choose the word with highest score | ||
if current_score > highest_score: | ||
highest_word= word | ||
highest_score = current_score | ||
|
||
#If a tie and no word is 10 char, pick the shortest word | ||
elif current_score == highest_score \ | ||
and len(word) < len(highest_word) \ | ||
and len(highest_word) != 10: | ||
highest_word = word | ||
|
||
#If a tie and one word is 10 char, pick that word | ||
elif len(word) == 10 \ | ||
and len(highest_word) != 10: | ||
highest_word = word | ||
|
||
return (highest_word, highest_score) | ||
This file contains hidden or 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
This file contains hidden or 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
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.
Great work using that debugger and getting this code working! You are a debugger pro! 🪲