forked from AdaGold/adagrams-py
-
Notifications
You must be signed in to change notification settings - Fork 89
Tigers: Sunny and Marie - Adagrams #65
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
mkeefer17
wants to merge
22
commits into
Ada-C18:master
Choose a base branch
from
mkeefer17: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.
Open
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
b577367
Adds time zones to README
mkeefer17 36d97b3
work on first function
mkeefer17 c884eb2
modified game.py file so we would stop getting a discovery error, aka…
sunnybysunny 7c1ac3b
modified function draw_letters, tests 1 and 2 in Wave 01 are now passing
sunnybysunny b1576bd
modified function draw_letters now all tests in wave 01 pass
sunnybysunny 0a9c620
added comments to explain code, and also added a body to the function…
sunnybysunny 1d8376b
modified function uses_available_letters, test 4 in wave 02 now passes
sunnybysunny cfa0b9f
added an idea for uses_available_words function to solve for test 5 u…
sunnybysunny f8175e1
modified function uses_available_letters all tests in wave 02 pass
sunnybysunny 3ad05d8
passes all tests in wave 3
mkeefer17 0289e4c
Merge branch 'master' of https://github.com/mkeefer17/adagrams-py
mkeefer17 398a454
created function get_highest_word_score tests 1,2,4,5,and 7 pass in w…
sunnybysunny 3fea010
modified function get_highest_word_score, all tests in wave 04 pass, …
sunnybysunny 08c9f4b
additional work on wave four
mkeefer17 4f72944
Merge branch 'master' of https://github.com/mkeefer17/adagrams-py
mkeefer17 b26ed6f
modified get highest_word_score function all tests in wave 04 pass
sunnybysunny 902eb62
implemented suggestion for refactoring function draw letters
sunnybysunny 4b1c0fe
implemented suggestion to refactor function uses available word
sunnybysunny ebca07d
implemented suggested syntax refactoring
sunnybysunny da21ee2
implemented suggestion to refactor function get highest word score th…
sunnybysunny 6ebaf6a
finished implementing all suggestions for refactoring from pull reque…
sunnybysunny 596a592
refactored draw ten letters to implement a for loop instead of a whil…
sunnybysunny 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,4 +1,5 @@ | ||
# AdaGrams | ||
#-- Sunny: Mountain time. Marie: Eastern | ||
|
||
## Skills Assessed | ||
|
||
|
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,154 @@ | ||
import random | ||
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_CHART = { | ||
('A', 'E', 'I', 'O', 'U', 'L', 'N', 'R', 'S', 'T'): 1, | ||
('D', 'G'): 2, | ||
('B', 'C', 'M', 'P'): 3, | ||
('F', 'H', 'V', 'W', 'Y'): 4, | ||
('K'): 5, | ||
('J', 'X'): 8, | ||
('Q', 'Z'): 10 | ||
} | ||
|
||
def draw_letters(): | ||
pass | ||
letter_pool_list = [] | ||
my_ten_letters = [] | ||
|
||
for letter in LETTER_POOL: | ||
for num in range(0,(LETTER_POOL[letter])): | ||
letter_pool_list.append(letter) | ||
|
||
#Claire's suggestion for a while loop | ||
|
||
|
||
for i in range(10): | ||
random_letter = random.choice(letter_pool_list) | ||
my_ten_letters.append(random_letter) | ||
letter_pool_list.remove(random_letter) | ||
return my_ten_letters | ||
|
||
#original solution | ||
|
||
# while len(my_ten_letters) < 10: | ||
# for num in range(0,10): | ||
# random_letter = random.choice(letter_pool_list) | ||
# my_ten_letters.append(random_letter) | ||
# my_string_count = my_ten_letters.count(random_letter) | ||
# word_pool_count = letter_pool_list.count(random_letter) | ||
# if my_string_count > word_pool_count: | ||
# my_ten_letters.remove(random_letter) | ||
|
||
def uses_available_letters(word, letter_bank): | ||
pass | ||
|
||
word = word.upper() | ||
# Claire's suggestion to combine the foor loops | ||
for letter in word: | ||
count_pool_letter = letter_bank.count(letter) | ||
count_word_letter = word.count(letter) | ||
if letter not in letter_bank: | ||
return False | ||
if count_word_letter > count_pool_letter: | ||
return False | ||
else: | ||
continue | ||
return True | ||
|
||
# original for solution | ||
# word = word.upper() | ||
# letter_results = [] | ||
# for letter in word: | ||
# if letter not in letter_bank: | ||
# letter_results.append("f") | ||
# if "f" in letter_results: | ||
# return False | ||
# else: | ||
# return True | ||
|
||
# for letter in word: | ||
# count_pool_letter = letter_bank.count(letter) | ||
# count_word_letter = word.count(letter) | ||
# if count_word_letter > count_pool_letter: | ||
# return False | ||
# else: | ||
# 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 | ||
|
||
if len(word) == 0: | ||
return 0 | ||
|
||
word_score = 0 | ||
word = word.upper() | ||
|
||
if len(word) in range(7, 11): | ||
word_score += 8 | ||
|
||
for letter in word: | ||
for key in SCORE_CHART: | ||
if letter in key: | ||
word_score += SCORE_CHART.get(key) | ||
return word_score | ||
|
||
def get_highest_word_score(word_list): | ||
pass | ||
|
||
score_dict = {} | ||
for word in word_list: | ||
score = score_word(word) | ||
score_dict[word] = score | ||
|
||
highest_score_value = max(score_dict.values()) | ||
|
||
highest_scores = [] | ||
|
||
#Claire's suggestion for more descriptive syntax | ||
for word, score in score_dict.items(): | ||
if score == highest_score_value: | ||
highest_scores.append([word,score]) | ||
|
||
# original solution | ||
# for dict in score_dict.items(): | ||
# if dict[1] == highest_score_value: | ||
# highest_scores.append(dict) | ||
|
||
shortest_word_length = len(highest_scores[0][0]) | ||
shortest_word = highest_scores[0][0] | ||
|
||
if len(highest_scores) > 1: | ||
for word, score in highest_scores: | ||
if len(word) >= 10: | ||
shortest_word = word | ||
return (shortest_word, highest_score_value) | ||
elif len(word) < shortest_word_length: | ||
shortest_word_length = len(word) | ||
shortest_word = word | ||
return (shortest_word, highest_score_value) | ||
|
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.
Good idea here! This will allow for a better distribution of probability when picking letters randomly.