Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
This comment is hidden because it contains spoiler information about the solution
Great solution, but \w would match digits and underscore. Per description "word" is a sequence of alphabetical characters.
Prime numbers are natural numbers greater than 1 (kata's description even mentions that), so there's no need to check divisors of negative numbers, just return false.
This comment is hidden because it contains spoiler information about the solution
Loved your solution!
Other upvoted solutions are slow as hell and yours is even faster than mine.
Kudos!
Only problem for me is that method .delete_if mutates the caller.
Value of "order" was changed. Method .reject would suit me be better in this case.
Nevertheless great solution!
This comment is hidden because it contains spoiler information about the solution
It's an offset. It sets starting value of the index (default is 0).
https://ruby-doc.org/core-2.4.1/Enumerator.html#method-i-with_index
Clever solution!
Though if you'd use single quotes in a gsub/sub, you wouldn't have to escape first reference twice, just once.
Great kata!
Though, I'd change method name in Ruby translation to snake case.
Great solution!
Though, I think it would've been better to use string anchors instead of line anchors:
Otherwise how_much_coffee("\ncat") would return 1 instead of 0.
Here you assign true to every bonus.
I'd assume you wanted to check if bonus is equal to true, you should've used (bonus == true || false).
But since bonus is a Boolean type (true or false), I don't see a point.
Same mistake: first you assign true to the bonus and then you're checking if bonus is true (it will never be false).
You should've used:
or even better
This comment is hidden because it contains spoiler information about the solution
I think that bad indentation might be caused by copying code from text editor/IDE.
Thanks for the clarification on returns!
I've been trying to follow bbatsov ruby style guide, but whatever suits everyone best.
It's the last line of the method, so no need to explicitly return a
Loading more items...