-
Notifications
You must be signed in to change notification settings - Fork 33
Leaves - Katie and Dominique #18
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?
Conversation
AdagramsWhat We're Looking For
|
sum = 0 | ||
total_sum = 0 | ||
|
||
score_hash = {1=> ["A", "E", "I", "O", "U", "L", "N", "R", "S", "T"], 2=> ["D", "G"], |
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.
An alternative approach would be to store the letter scores in a hash, something like this:
LETTER_SCORES = {
"A" => 1
"B" => 3,
"C" => 3,
"D" => 2,
# ...
}
Then to get the score for a letter, you can say LETTER_SCORES[letter]
.
You could create this hash from your original array of hashes raw_tiles
Organizing the data this way would simplify the logic below.
# Return word and score of word with highest score | ||
def highest_score_from(words) | ||
high_score_hash = {word: "", score: 0} | ||
high_score = 0 |
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.
We reworked the logic for this method and you don't end up using high_score and high_score_length. Rake provided this warning for you:
/Users/becca/Documents/GitHub/c12/adagrams/lib/adagrams.rb:90: warning: assigned but unused variable - high_score
/Users/becca/Documents/GitHub/c12/adagrams/lib/adagrams.rb:91: warning: assigned but unused variable - high_score_length
/Users/becca/Documents/GitHub/c12/adagrams/lib/adagrams.rb:46: warning: assigned but unused variable - letters_in_hand
You should remove these variables from your code.
return word1 | ||
end | ||
|
||
|
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.
For the sake of cleanliness, remove these extra lines.
|
||
tile_set = [] | ||
|
||
# extracts letter and score keys and puts them in array called raw_tiles |
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.
Clever use of the data structure you created. Consider also how you could use a data structure organized like this: {"A"=>9, "B"=>2,...}
Adagrams
Congratulations! You're submitting your assignment.
Comprehension Questions
Enumerable
mixin? If so, where and why was it helpful?