forked from AdaGold/adagrams-py
-
Notifications
You must be signed in to change notification settings - Fork 49
C22 - Charday N. #32
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
chardayneal
wants to merge
11
commits into
Ada-C22:main
Choose a base branch
from
chardayneal: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
C22 - Charday N. #32
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
bd1cd52
Completed draw_letters function, one test in wave 1 passes
chardayneal 445ea68
Complete draw letters, wave 1 tests complete
chardayneal 8daec7b
Complete uses_available_letters(), wave 2 tests complete
chardayneal 1d46bb4
Complete score_word(), wave 3 tests complete
chardayneal 53e077c
Complete get_highest_word_score(), wave 4 complete
chardayneal 11d23cf
Review code
chardayneal eefda59
Refactor game.py
chardayneal 83f26f0
Update letter_pool to correct distributed weight and draw_letters fun…
chardayneal c977165
Update LETTER_POINTS data structure and score_word function
chardayneal 929527c
Update get_highest_word_score function logic
chardayneal b1a1e40
Update with consistent spacing
chardayneal 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,104 @@ | ||
import random | ||
|
||
LETTER_POOL = ["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"] | ||
|
||
LETTER_POINTS = { | ||
"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 draw_letters(): | ||
pass | ||
letter_pool = LETTER_POOL.copy() | ||
chosen_letters = [] | ||
|
||
while len(chosen_letters) < 10: | ||
random_index = random.randint(0,len(letter_pool)-1) | ||
random_letter = letter_pool.pop(random_index) | ||
chosen_letters.append(random_letter) | ||
|
||
return chosen_letters | ||
chardayneal marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
def uses_available_letters(word, letter_bank): | ||
pass | ||
if len(word) > len(letter_bank): | ||
return False | ||
chardayneal marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
available_letters_dict = {} | ||
for letter in letter_bank: | ||
if letter in available_letters_dict.keys(): | ||
available_letters_dict[letter] += 1 | ||
continue | ||
available_letters_dict[letter] = 1 | ||
|
||
for letter in word.upper(): | ||
if letter not in available_letters_dict.keys() or not available_letters_dict[letter] : | ||
return False | ||
available_letters_dict[letter] -= 1 | ||
|
||
return True | ||
chardayneal marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
def score_word(word): | ||
pass | ||
score = 0 | ||
for letter in word.upper(): | ||
if letter in LETTER_POINTS: | ||
score += LETTER_POINTS[letter] | ||
|
||
if len(word) >= 7 and len(word) < 11: | ||
score += 8 | ||
|
||
return score | ||
|
||
|
||
def get_highest_word_score(word_list): | ||
pass | ||
highest_word = "" | ||
highest_score = 0 | ||
|
||
for word in word_list: | ||
word_score = score_word(word) | ||
|
||
if word_score > highest_score: | ||
highest_word = word | ||
highest_score = word_score | ||
|
||
elif word_score == highest_score: | ||
if len(word) == len(highest_word): | ||
continue | ||
elif len(highest_word) == 10: | ||
continue | ||
elif len(word) == 10: | ||
highest_word = word | ||
highest_score = word_score | ||
elif len(word) < len(highest_word): | ||
highest_word = word | ||
highest_score = word_score | ||
|
||
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
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.
Uh oh!
There was an error while loading. Please reload this page.