-
Notifications
You must be signed in to change notification settings - Fork 89
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
Lions - Nancy L. #82
base: master
Are you sure you want to change the base?
Lions - Nancy L. #82
Changes from all commits
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,8 +1,62 @@ | ||
import random | ||
|
||
def draw_letters(): | ||
pass | ||
#available letters should be in a dictionary | ||
available_letters = { | ||
"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 | ||
} | ||
# start with an empty list of available letters to use | ||
hand_available = [] | ||
""" | ||
THIS IS WHAT THE INSTRUCTOR HELPED ME TO ACOMPLISH | ||
for _ in range(10): | ||
letters = [] | ||
for letter, quantity in available_letters.items(): | ||
for _ in range(quantity): | ||
letters.append(letter) | ||
|
||
selection = random.choice(letters) | ||
hand_available.append(selection) | ||
available_letters[selection] = available_letters[selection] - 1 | ||
Comment on lines
+20
to
+28
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. This works well! Nice use of a list of all the available letters to make |
||
""" | ||
|
||
# iterate through the length of dictionary of letters/quantity available (key:value) | ||
for letter, quantity in available_letters.items(): | ||
# # randomly choose a letter in the dictionary using keys | ||
# selection = random.choice(list(available_letters.keys()) -I was unable to get this to work in the loop- | ||
selection = random.choice(letter) | ||
# if the user list has < 10 letters | ||
if len(hand_available) < 10: | ||
# # if the quantity of the letter is not 0 (value) | ||
if quantity != 0: | ||
# # add the letter to the empty list | ||
hand_available.append(selection) | ||
# # subtract that number from the amounts available | ||
quantity -= 1 | ||
Comment on lines
+31
to
+43
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. I like the idea here, but it unfortunately doesn't quite work. Here we're looking at the letters one at a time in the order they appeared in the dictionary. Because we're just looking at one letter at a time, |
||
|
||
return hand_available | ||
|
||
|
||
def uses_available_letters(word, letter_bank): | ||
pass | ||
for letter in word: | ||
if letter in letter_bank: | ||
return True | ||
elif letter not in letter_bank or len(word) > len(letter_bank): | ||
return False | ||
Comment on lines
48
to
+53
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. This is on the right track! There are two main issues:
|
||
|
||
# if every letter in the word is found in the letter_bank: | ||
# return True | ||
# if every letter in the word is not in the letter_bank or | ||
# exceedes the len() of the letter_bank: | ||
# return False | ||
|
||
def score_word(word): | ||
pass | ||
|
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.
Smart to include dictionary here!