Adagrams Submission - Danielle & Alice#2
Open
danimetz wants to merge 17 commits intoAda-C10:masterfrom
Open
Conversation
…creating check array
…le does not run because it does not recognize csv file
Wave 3 - 5
wave 5 works
… passed using rake
dHelmgren
reviewed
Aug 23, 2018
| count = 0 | ||
| while count < 10 do | ||
| index = rand(0...letter_probability.length) | ||
| if letter_probability[index] != 0 |
There was a problem hiding this comment.
So, this works, but you end up with an array that becomes more and more likely to "bounce" as you pick letters from the pile. Instead of nulling the value at the index, why not remove just that element from the array? That way, you don't waste loops through on no-ops (no operation).
dHelmgren
reviewed
Aug 23, 2018
| return false | ||
| else | ||
| input.each do |letter| | ||
| input.count(letter) > letters_in_hand.count(letter) ? value << false : value << true |
There was a problem hiding this comment.
You are doing more work than you need to! As soon as one of these checks comes up false, you can return false, right? The only case that requires you to complete the loop is if every letter matches!
dHelmgren
reviewed
Aug 23, 2018
| input.count(letter) > letters_in_hand.count(letter) ? value << false : value << true | ||
| end | ||
| end | ||
| value.all? true ? true : false |
There was a problem hiding this comment.
value.all? is hiding a second loop from you!
AdagramsWhat We're Looking For
|
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?