-
Notifications
You must be signed in to change notification settings - Fork 27
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
Divya and Daniela's Adagrams #3
base: master
Are you sure you want to change the base?
Conversation
AdagramsWhat We're Looking For
|
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 ] | ||
|
||
return (all_letters.shuffle).first(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.
I love this. Nice one liner!
if hand_copy.include?(alphabet) | ||
hand_copy.delete_at(hand_copy.index(alphabet)) | ||
else | ||
value = false |
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.
Why wait until the loop is finished to return this false? If the first element fails, is there any reason to keep checking?
word_array = word.upcase.split('') | ||
scores = word_array.map do |letter| | ||
score_hash[letter] | ||
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.
A different enumerable would allow you to do this with only one loop! Think about how inject/reduce could be used here.
|
||
best_word_list = words_with_scores.select{|word, score| score == best_score} | ||
|
||
best_word = 'reallybigtestword' |
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 shouldn't stay in your final code! Write a case to handle when there is not a current best word, rather than relying on the first entry in best_word_list
being overwritten.
Adagrams
Congratulations! You're submitting your assignment.
Comprehension Questions
Enumerable
mixin? If so, where and why was it helpful?