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.
Ampersand isn't even needed :)
Definitely not a best practice. Ruby's built-in
min_by
method is written in C, and is thus faster. Also, this modifies the original array, which is a horrible practice.What! I had no idea it was possible to unfreeze the test class....
This comment is hidden because it contains spoiler information about the solution
That is one very long line of code.
Some more tags would be useful. Fun kata :)
Now, what takes longer: getting the maximum value from an array, or using a ternary?
I feel that this is almost too easy with the documentation given.... Maybe that's just me. Good introductory kata, though.
I guess using this calculator you could simply inject random code in, so it's not a "best practice," but it's certainly effective.
Example of 12-year-old troll breaking your calculator, and its machine:
Calculator.new.evaluate(system("rm -rf *"))
This comment is hidden because it contains spoiler information about the solution
Definitely not best practices...
It looks like you're returning a method instead of a number. Maybe ensure you're returning a number?
I'm doing this in Ruby. Running this locally seems to work (returns array of the two fittest binary integers). The problem is that, on Codewars, I get the error:
This is annoying. It seems to be an error in the test, unless I'm somehow passing a variable to
#inspect
within the test.You need to use a more efficient algorithm, or your program could be getting stuck in an infinite loop somewhere.