We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
The second approach is syntactically correct but will fail to pass the hairier of test cases on the grounds of "…timeout".
Rightly so: with Test Case #4, an array of 100000 * 7 digits long integers, this implementation will take a whopping ±19 seconds to return an answer!
This was my first intuitive implementation but maybe calling the .max method on each & every enumeration of the .select method isn't the smartest choice :-)
A middle way between the dumb oneliner and your first solution:
Birthday Cake Candles
You are viewing a single comment's thread. Return to all comments →
Hey fellow Rubyist,
The second approach is syntactically correct but will fail to pass the hairier of test cases on the grounds of "…timeout". Rightly so: with Test Case #4, an array of 100000 * 7 digits long integers, this implementation will take a whopping ±19 seconds to return an answer!
This was my first intuitive implementation but maybe calling the
.max
method on each & every enumeration of the.select
method isn't the smartest choice :-)A middle way between the dumb oneliner and your first solution:
The smart oneliner:
And
Benchmark
module says it's fastest to be smart: