forked from AdaGold/adagrams-py
-
Notifications
You must be signed in to change notification settings - Fork 57
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
C16 - Spruce - Sandra Caballero and Vange Spracklin #46
Open
HouseOfVange
wants to merge
9
commits into
Ada-C16:master
Choose a base branch
from
HouseOfVange:master
base: master
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.
+192
−4
Open
Changes from 1 commit
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
dcf52dd
add pseudocode for draw_letters function
HouseOfVange 746a4b5
added list and beginning of for loop in draw_letters
Sanderspat aa03d24
passes wave 1
HouseOfVange 846387e
completed LETTER_POOL
Sanderspat b52a7b0
pseudo code for wave 2, 3, 4
HouseOfVange 07681e5
completes wave 2
Sanderspat e9f6be3
completes wave 3
Sanderspat 430015c
completes wave 4
Sanderspat 2a34956
adds finishing edits
HouseOfVange 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
completes wave 2
commit 07681e5a146d777e86bc3b0641e5a44537dac808
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 |
---|---|---|
|
@@ -140,121 +140,38 @@ | |
) | ||
|
||
def draw_letters(): | ||
# create an empty list that will eventually hold | ||
# 10 strings, letter "hand of letters" | ||
hand_of_letters = [] | ||
|
||
# create an empty list that will eventually hold all | ||
# the letters in letter pool in accurate frequency. | ||
# example of how list will eventually look like: | ||
# letter_pool_list = ["A","A","A","A","A","A","A","A","A","B","B" etc...] | ||
letter_pool_list = [] | ||
|
||
# iterate through the LETTER_POOL tuple with a forloop | ||
# append each key (which will be a string like "A" or "B") to the list | ||
# letter_pool_list the appropriate number of times aka the value (which will be | ||
# an int like 9 or 2). | ||
|
||
for letter_dict in LETTER_POOL: | ||
for key in letter_dict: | ||
freq = letter_dict[key]["frequency"] | ||
for i in range(0, freq): | ||
letter_pool_list.append(key) | ||
|
||
# create a for loop that will run 10x | ||
# generate a random int | ||
# select a string from letter_pool_list with the index position random int | ||
# example: letter_pool_list[random_int] | ||
# use the pop(index) function to remove the string at index random_int. | ||
# append the popped value to hand of letter list | ||
|
||
for i in range(10): | ||
index = random.randint(0, len(letter_pool_list)-1) | ||
letter = letter_pool_list[index] | ||
hand_of_letters.append(letter) | ||
letter_pool_list.pop(index) | ||
|
||
# return a list that contains 10 strings ["A", "B", "C" etc... | ||
return hand_of_letters | ||
|
||
def uses_available_letters(word, letter_bank): | ||
#make a copy of the list letter_bank for safe to operate on and change | ||
letter_bank_copy = letter_bank[:] | ||
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. Great use of the slice operator to make a shallow copy. |
||
|
||
# make a list of characters in the word variable (which is a string) | ||
word_character_list = list(word) | ||
|
||
# create a loop | ||
count = 0 | ||
for letter in word_character_list: | ||
if letter in letter_bank_copy: | ||
print(letter) | ||
letter_bank_copy.pop() | ||
count += 1 | ||
letter_bank_copy.remove(letter) | ||
print(letter_bank_copy) | ||
else: | ||
print(f"The letter {letter} is unavailale") | ||
letter_bank_copy.pop() | ||
# create an if statement that compares the letters in the letter bank with the letters | ||
# in the word | ||
|
||
# use the pop function to remove a letter from the letter bank copy once it's been | ||
# compared with a letter in the word | ||
|
||
|
||
# returns a boolean value. | ||
# True if the word can be spelled with the 10 letters | ||
# in the list "letter_bank" that we are passed. | ||
# False if the word cannote be spelled. | ||
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 | ||
# create a variable for the total_score, set the score to 0 | ||
|
||
# make the string variable we are passed ALL CAPS with the upper() function | ||
# that way each character in our word will match the dictionary keys in LETTER_POOL | ||
# example: word = word.upper() | ||
|
||
# make a 3 nested for loops (indentation indicates scope) | ||
# iterate through each character in the word variable | ||
# iterate through each element (we used "letter_dict" in the first function) in LETTER_POOL | ||
# iterate through each key in the "letter_dict" to access it's value, which is another dictionary with data about the letter frequency and point value. | ||
# i got this expression from the iterating over dictionaries lesson in Learn: "for letter, letter_data in letter_dict.items():" | ||
# i'm not sure how to word what it's doing. | ||
# compare the key of the dictionary (which will be a letter) to the character in the word from the first loop. if they match add the letter's point | ||
# value to the variable total_score | ||
|
||
# evaluate the length of the word variable | ||
# make an if statement where if the word is longer than 7 characters add 8 points to total_score | ||
|
||
# return total_score variable | ||
|
||
def get_highest_word_score(word_list): | ||
|
||
pass | ||
# create an empty list variable (best_word) that will eventually hold the best word's data | ||
# where the first value is the string of the word and the second value is the point value | ||
# example: best_word = ["reallygoodword", 14] | ||
|
||
#create an empty string variable that will eventually hold the word with the most points (top_word) | ||
|
||
#create a variable for the top score and set it to zero (top_score) | ||
|
||
# iterate through each word in word_list and calculate it's score with the score_word function | ||
# compare the score to the variable top_score with if statements. | ||
# if the score is bigger than top_score, make that word the top_word and that score top_score | ||
# if the score is a tie compare the length of each word with if statements | ||
# if one word has exactly 10 letters in it, thats the top_word | ||
# if both words have 10 letters the word with the lowest index in word_list is top_word | ||
# if neither of the words have 10 letters the shorter word it top_word | ||
|
||
|
||
#return the best_word list with top_word as the first value and top_score as the 2nd value | ||
# best_word = [top_word, top_score] | ||
|
||
letter_bank_test = draw_letters() | ||
print(letter_bank_test) | ||
water_character_list = list("WATER") | ||
|
||
["W", "A", "T", "E", "R"] | ||
|
||
|
||
uses_available_letters("WATER", letter_bank_test) | ||
|
||
print(letter_bank_test) | ||
def get_highest_word_score(word_list): |
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.
👍