Conversation
droberts-sea
left a comment
There was a problem hiding this comment.
Adagrams
What We're Looking For
| Feature | Feedback |
|---|---|
| General | |
| Answered comprehension questions | yes |
| Small commits with meaningful commit messages | yes |
| Code Requirements | |
draw_letters method |
|
| Uses appropriate data structure to store the letter distribution | yes |
All tests for draw_letters pass |
yes |
uses_available_letters? method |
|
All tests for uses_available_letters? pass |
yes, but see inline |
score_word method |
|
| Uses appropriate data structure to store the letter scores | see inline |
All tests for score_word pass |
yes |
highest_score_from method |
|
| Appropriately handles edge cases for tie-breaking logic | yes |
All tests for highest_score_from pass |
yes |
| Overall |
Good job overall! I've left a few inline comments, and you need to get your indentation figured out, but in general I'm happy with what I see here. It is clear to me that the learning goals for this assignment were met. Keep up the hard work!
| end | ||
|
|
||
|
|
||
| draw_letters |
There was a problem hiding this comment.
You don't need to call draw_letters here. Your job is to define the method, the tests and the wave_X_game.rb will handle calling it.
| { word: element, score: score_word(element) } | ||
| end | ||
|
|
||
| find_best_word = [] |
There was a problem hiding this comment.
Watch your indentation through here. Have you installed rubocop and rufo to automatically adjust your formatting?
| letters = [ | ||
| "A", "A", "A", "A", "A", "A", "A", "A", "A", | ||
| "B", "B", | ||
| "C", "C", |
There was a problem hiding this comment.
This data would be a great thing to store in a constant!
| if index.nil? | ||
| return false | ||
| else | ||
| letters_in_hand.delete_at(index) |
There was a problem hiding this comment.
When you call delete_at here, you modify the original hand of letters! While that makes the tests pass, it also introduces a bug:
hand = ['A', 'B', 'C']
word = 'ABC'
puts uses_available_letters?(word, hand)
# => true
puts uses_available_letters?(word, hand)
# => falseHow might you address this problem?
| case letter | ||
| when "A", 'E', 'I', 'O', 'U', 'L', 'R', 'N', 'S', 'T' | ||
| score += 1 | ||
| when 'D', 'G' |
There was a problem hiding this comment.
While this case statement works, it means that the information about which letter has which score is locked into this piece of code, and can't easily be used elsewhere. For example, if you wanted to display the value of each letter in a hand, you would need to repeat this work.
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].
| end | ||
| end | ||
| p find_best_word | ||
| winner = find_best_word.first |
There was a problem hiding this comment.
Please remove debugging output (like line 100) before submitting projects.
Adagrams
Congratulations! You're submitting your assignment.
Comprehension Questions
Enumerablemixed in? If so, where and why was it helpful?