Conversation
AdagramsWhat We're Looking For
|
|
|
||
| puts "Using the following letters, create an Adagram" | ||
| hand = draw_letters | ||
| puts hand |
There was a problem hiding this comment.
I'm not sure how exactly you were testing your code, but these lines in between the methods kept me from being able to use the rake command to test your code.
| if letters_in_hand.include?(input[i]) == true | ||
| letters_in_hand.delete(input[i]) | ||
| else | ||
| result = false |
There was a problem hiding this comment.
I'll leave this as a "vague thing" to think about: I think that while you iterate through input.chars, you can actually determine that uses_available_letters? can return false before the loop finishes.
Remember, when you use the return keyword, it will kick the program execution out of the method early, and return whatever value you give it.
| adagram_input = gets.chomp.to_s.upcase | ||
|
|
||
| def uses_available_letters?(input, letters_in_hand) | ||
| letters_array = input.chars |
There was a problem hiding this comment.
There doesn't seem to me a good reason to make this re-assignment. In your while you could have just as easily done input.chars.length.
| i = 0 | ||
| while i < 26 | ||
| number_of_letters[i].times do | ||
| letter_pool.push(letters[i]) |
There was a problem hiding this comment.
I like how you did this. It shows a good understanding of the language!
| word_array.each do |word| | ||
| if word == input.downcase | ||
| input_in_dictionary = true | ||
| end |
There was a problem hiding this comment.
As above, you could leverage the return keyword here to just bail from the loop as soon as you have the answer.
| i = i + 1 | ||
| end | ||
|
|
||
| return letter_pool.sample(10) |
Adagrams
Congratulations! You're submitting your assignment.
Comprehension Questions
Enumerablemixin? If so, where and why was it helpful?