-
Couldn't load subscription status.
- Fork 57
Maple- Adah Hailemariam and Genie Arcila #45
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
base: master
Are you sure you want to change the base?
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,11 +1,72 @@ | ||
| import random | ||
|
|
||
| def draw_letters(): | ||
| pass | ||
|
|
||
| letter_list = ['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'] | ||
| letters = letter_list.copy() | ||
| chosen_letters = [] | ||
| for i in range(10): | ||
|
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. instead of a for loop, you could use a while loop that will continue until the length of |
||
| letter = random.choice(letters) | ||
| letters.remove(letter) | ||
| chosen_letters.append(letter) | ||
| return chosen_letters | ||
|
|
||
| def uses_available_letters(word, letter_bank): | ||
| pass | ||
|
|
||
| letters_used = letter_bank.copy() | ||
|
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. yay for making a copy! Definitely want to avoid side effects. |
||
| for letter in word: | ||
| if letter in letters_used: | ||
| letters_used.remove(letter) | ||
| else: | ||
| return False | ||
| break | ||
|
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. the break is unnecessary here. Once you return False the code after will be unreachable. |
||
| return True | ||
|
|
||
| def score_word(word): | ||
| pass | ||
|
|
||
| letter_points = { | ||
| 1:['A', 'E', 'I','O', 'U', 'L', 'N', 'R', 'S', 'T' ], | ||
| 2:['D', 'G' ], | ||
| 3:['B', 'C', 'M', 'P' ], | ||
| 4:['F', 'H', 'V', 'W', 'Y' ], | ||
| 5:['K'], | ||
| 8:['J', 'X'], | ||
| 10:['Q', 'Z'] | ||
|
Comment on lines
+34
to
+40
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 way to group the data that was given |
||
| } | ||
| sum = 0 | ||
| word_length = len(word) | ||
| cap_word = word.upper() | ||
| for letter in cap_word: | ||
| for score in letter_points: | ||
| if letter in letter_points[score]: | ||
| sum += score | ||
| if word_length >= 7: | ||
| sum += 8 | ||
| return sum | ||
|
|
||
| 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. Great way to approach finding the highest score. |
||
| pass | ||
| words_and_scores = [] | ||
| for word in word_list: | ||
| score = score_word(word) | ||
| words_and_scores.append(tuple([word, score])) | ||
| num=(0, 0) | ||
| for item in words_and_scores: | ||
| if item[1]>num[1]: | ||
| num=item | ||
| elif item[1]==num[1]: | ||
| if len(num[0])==10: | ||
| break | ||
| elif len(item[0])==len(num[0]): | ||
| break | ||
| elif len(item[0])==10: | ||
| num=item | ||
| break | ||
| elif len(item[0])<len(num[0]): | ||
| num=item | ||
| return num | ||
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.
I would suggest making your letter_list a global constant variable
LETTER_LISTthis would clean up your function and remind yourself/other developers this should not be changed