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.
Perhaps unhonorable but pretty instructional in other languages like Java! http://www.codewars.com/kata/sort-arrays-1/forks/java ( not sure if the correct link should be http://www.codewars.com/kumite/56ce5b40aa4ac74e65001e16?sel=56ce5b40aa4ac74e65001e16 ) :P
This comment is hidden because it contains spoiler information about the solution
It's worth noting that you discard the candidates with the least number of votes including no votes during each round. If you get the error above, it's reasonably likely that you discarded the person who was voted for in the first round with the least number of votes, ignoring that some candidates were not voted for, and thus, had fewer votes.
It's the most straightforward way in Ruby AFAIK. Maybe handling the case where
str.nil? == true
makes for a bulletproof answer, but the tests don't run thenil
value, so you can get away without.I did this one in Ruby, basically using the
reverse
method. Is this also considered a naive answer?I have tried it in Iceweasel (x64) and regexp seems very fast if you don't use custom replacement functions.
Nice -- jsperf.com is handy. I added a couple more tests just to see, and it looks like the simple regexp one is probably the way to go -- legible and fast.
"... now they have two problems."
Bizarre, but fun. I wouldn't go this way for maintainability/legibility reasons, but it's cool anyhow.
I wish CodeWars would also run a larger set of test cases and give you some performance characteristics, I'd be curious to see how this performs against a simpler regexp solution.
This comment is hidden because it contains spoiler information about the solution
The two parameters are Date objects, which include times.
True enough. My coffeescript still has remnants of Javascript in it.
Somehow this solution feels more 'functional' to me, although the iterative approach taken by almost all the other solutions is perhaps more logical.
Would be nice if the question were clear as to whether or not the returned value should be an integer or floating point. (That is, if 4.123 seconds have elapsed, what should the function return?)
This comment is hidden because it contains spoiler information about the solution
Loading more items...