-
Notifications
You must be signed in to change notification settings - Fork 29
Sockets - Nidhi and Riyo #9
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
base: master
Are you sure you want to change the base?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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) |
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.
Sample is a good choice here!
Adagrams
Congratulations! You're submitting your assignment.
Comprehension Questions
Enumerablemixin? If so, where and why was it helpful?