Conversation
| scored_words << {:word => word, :score => score_word(word)} | ||
| end | ||
|
|
||
| highest_scored_word = scored_words.max_by do |scored_words| |
There was a problem hiding this comment.
scored_words here does a weird thing to your scored_words from line 93. Make sure to check your error messages before you submit your code! https://en.wikipedia.org/wiki/Variable_shadowing
There was a problem hiding this comment.
You could easily avoid this by calling the line thusly:
highest_scored_word = scored_words.max_by do |word|| end | ||
|
|
||
| if highest_score_array.length > 1 | ||
| highest_scored_word = highest_score_array.min_by { |words| words[:word].length } |
There was a problem hiding this comment.
again, this words variable is shadowing something. This one not causing any harm, but it CAN do really weird and bad stuff. In the same scope, try to use unique names.
| letter_pool = make_letter_pool(letter_pool, "H", 2) | ||
| letter_pool = make_letter_pool(letter_pool, "I", 9) | ||
| letter_pool = make_letter_pool(letter_pool, "J", 1) | ||
| letter_pool = make_letter_pool(letter_pool, "K", 1) |
There was a problem hiding this comment.
I don't think this formatting makes this any easier to read. This takes up more space than a loop would have, and more space than hard-coding an array would have.
| 10.times do | ||
| curr_letter = letter_pool.sample | ||
| user_hand.push(curr_letter) | ||
| available_letters.delete(curr_letter) |
There was a problem hiding this comment.
This letter generation method will never result in duplicate letters, because the .delete method deletes all of the curr_letter in the array.
| input_letters = input.chars | ||
| input_letters.each do |letter| | ||
| if letters_in_hand.include?(letter) | ||
| letters_in_hand.delete(letter) |
There was a problem hiding this comment.
This never got caught because of draw letters, but this code would break for sets with duplicate letters, because .delete removes duplicates.
AdagramsWhat We're Looking For
|
Adagrams
Congratulations! You're submitting your assignment.
Comprehension Questions
Enumerablemixin? If so, where and why was it helpful?