Sockets - Kirsten and Cyndi#5
Open
kanderson38 wants to merge 6 commits into
Open
Conversation
AdagramsWhat We're Looking For
|
dHelmgren
reviewed
Mar 4, 2019
| letters_array = [] | ||
| i = 0 | ||
| until i == 10 | ||
| char = LETTER_POOL.to_a.sample[0] |
There was a problem hiding this comment.
By this logic, you're as likely to draw an e as you are a z!
Instead, you might create an array containing all the letters, with code similar to this:
letter_counts = {
# the hash you had before
}
letters = []
letter_counts.each do |letter, count|
count.times do
letters << letter
end
endThen you could pull a random tile with letters.sample and get a nice even distribution.
| check = true | ||
| input.split("").each do |char| | ||
| if !popping_array.include?(char) | ||
| check = 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adagrams
Congratulations! You're submitting your assignment.
Comprehension Questions
Enumerablemixin? If so, where and why was it helpful?