-
Notifications
You must be signed in to change notification settings - Fork 33
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
Leaves Morgan & Janice #11
base: master
Are you sure you want to change the base?
Conversation
AdagramsWhat We're Looking For
|
require 'csv' | ||
|
||
def draw_letters | ||
all_letters_hash = { |
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.
Consider making this hash a global variable assigned outside the method so that it can be used other place.
all_letters_array << letter | ||
end | ||
end | ||
letters_in_hand = all_letters_array.sample(10) |
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.
You should explicitly return letters_in_hand
. Note warning when you run rake:
"/Users/becca/Documents/GitHub/c12/adagrams/lib/adagrams.rb:38: warning: assigned but unused variable - letters_in_hand"
letter_count[letter] -= 1 | ||
if letter_count[letter] < 0 | ||
return false | ||
break |
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.
You don't need break
. When you return in a function, nothing is executed after the return.
|
||
def score_word(word) | ||
# Make new hash to store letters and point values | ||
points = { |
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.
Similar to all_letter_hash
, it would make sense to define this hash outside the method as a global variable using all caps.
if input_array.size >= 7 && input_array.size < 11 | ||
return total_points.sum + 8 | ||
end | ||
# if total_points.empty? |
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.
Remove unused commented code when you refactor.
return total_points.sum | ||
end | ||
|
||
# REPLACE HIGH SCORE HASH STEPS WITH A HELPER METHOD |
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.
This would be a great use of a helper method, and a good task for a refactor.
end | ||
|
||
# REPLACE HIGH SCORE HASH STEPS WITH A HELPER METHOD | ||
def highest_score_from(words) |
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.
The comments in this method are helpful and are an example of a good use of comments.
Adagrams
Congratulations! You're submitting your assignment.
Comprehension Questions
def
+ method signature (name and parameters) + code block +end
.Enumerable
mixin? If so, where and why was it helpful?.map
to convert letters into their corresponding points. It enabled us to alter the original array elegantly and without creating a hash at that point.puts
statements.