-
Notifications
You must be signed in to change notification settings - Fork 464
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
Ruby - Laura Perez" #18
Open
lauraemiliaperez
wants to merge
10
commits into
AdaGold:main
Choose a base branch
from
lauraemiliaperez: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
10 commits
Select commit
Hold shift + click to select a range
fe97c98
add a sentence in the README file
lauraemiliaperez b12bf22
create draw_letters function
lauraemiliaperez ac42714
check for letters in bank and ignores case
lauraemiliaperez 404bedf
write uses available letters
lauraemiliaperez dff43bc
write score_word
lauraemiliaperez 5d03c47
write get_highest_word_score
lauraemiliaperez 9a661e2
Erase some comments
lauraemiliaperez 104ba43
refactoring first wave and pass tests
lauraemiliaperez e2751ef
Functions for wave 2 and 4. Test for modifications
lauraemiliaperez e511171
Refactored version
lauraemiliaperez 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,5 +1,7 @@ | ||
# AdaGrams | ||
|
||
First project! | ||
|
||
## Skills Assessed | ||
|
||
- Following directions and reading comprehension | ||
|
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,142 @@ | ||
import random | ||
LETTER_HAND = 10 | ||
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_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 | ||
} | ||
|
||
# wave 1: | ||
|
||
def check_for_values(dict,list, letter): | ||
count_letter = list.count(letter) | ||
print(f"count letter: {count_letter}, letter {letter}") | ||
print(dict[letter]) | ||
if dict[letter] >= count_letter: | ||
return True | ||
else: | ||
return False | ||
|
||
def draw_letters(): | ||
pass | ||
|
||
hand_list = [] | ||
while len(hand_list) < LETTER_HAND: | ||
a_letter = random.choice(list(LETTER_POOL.keys())) | ||
hand_list.append(a_letter) | ||
value_enough_times = check_for_values(LETTER_POOL, hand_list, a_letter) | ||
if value_enough_times is True: | ||
continue | ||
else: | ||
hand_list.pop() | ||
|
||
return hand_list | ||
|
||
|
||
# Wave 2: | ||
def uses_available_letters(word, letter_bank): | ||
pass | ||
|
||
upper_word = word.upper() | ||
for letter in upper_word: | ||
if letter not in letter_bank: | ||
return False | ||
elif upper_word.count(letter) > letter_bank.count(letter): | ||
return False | ||
else: | ||
continue | ||
return True | ||
|
||
|
||
|
||
def score_word(word): | ||
pass | ||
|
||
word_upper = word.upper() | ||
lenght_of_word = len(word) | ||
total_score = 0 | ||
for letter in word_upper: | ||
if letter in SCORE_VALUES: | ||
total_score += SCORE_VALUES[letter] | ||
if lenght_of_word > 6: | ||
total_score += 8 | ||
|
||
return total_score | ||
|
||
|
||
|
||
# Wave 4: | ||
def higher_than(tuple1, tuple2): | ||
'''returns True if word1 ranks higher than word2''' | ||
score_word1 = tuple1[1] | ||
score_word2 = tuple2[1] | ||
if score_word1 == score_word2: | ||
lenght_word1 = len(tuple1[0]) | ||
lenght_word2 = len(tuple2[0]) | ||
if lenght_word1 == 10 and lenght_word2 != 10: | ||
return True | ||
if lenght_word2 == 10 and lenght_word1 != 10: | ||
return False | ||
return lenght_word1 < lenght_word2 | ||
return score_word1 > score_word2 | ||
|
||
|
||
def get_highest_word_score(word_list): | ||
pass | ||
best_tuple = None | ||
for word in word_list: | ||
current_tuple = word, score_word(word) | ||
if best_tuple is None or higher_than(current_tuple,best_tuple): | ||
best_tuple = current_tuple | ||
return best_tuple | ||
|
||
|
||
|
||
|
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
list = [("XXX",1),("XCV",4),("DDD",7)("DER", 9),("ERT",3)] | ||
list_b = ["XXX", "XXXX", "XX", "X"] | ||
|
||
for i in range(len(list)): | ||
print(list[i][0]) |
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
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
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
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
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 job using a helper variable!