-
Notifications
You must be signed in to change notification settings - Fork 27
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
Adagrams Submission - Danielle & Alice #2
base: master
Are you sure you want to change the base?
Conversation
…creating check array
…le does not run because it does not recognize csv file
Wave 3 - 5
wave 5 works
… passed using rake
count = 0 | ||
while count < 10 do | ||
index = rand(0...letter_probability.length) | ||
if letter_probability[index] != 0 |
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.
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).
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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!
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
value.all?
is hiding a second loop from you!
AdagramsWhat We're Looking For
|
Adagrams
Congratulations! You're submitting your assignment.
Comprehension Questions
Enumerable
mixin? If so, where and why was it helpful?