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
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.
This comment is hidden because it contains spoiler information about the solution
Hey! Check out jsperf.com, that's exactly what you're looking for! I've just checked this solution against my own (http://jsperf.com/regexpsplice). It was nearly the same in Chrome, but regexp seems to be slower in FF (on Linux x86).
Very nice solution by the way! (:
This comment is hidden because it contains spoiler information about the solution
I think that for the purposes of this kata, you might want to just update the description saying that the string will always be comprised of straight UTF-8 characters — that's BY FAR the most common use-case, and it keeps this within the 7-kyu realm. And then potentially build another kata that has a much tougher skill level assignment and explicitly mentions that the string might include UTF-16 characters, and then build test cases like those mentioned in the SO link.
That is a good catch, cool answer... not cool.
Good catch, thanks for the heads-up.
Agreed. It would also have been nice to be clear about what was expected if start_time was greater than end_time.
Oh, ok... It was what I was doing but on the opposite direction...
Same here, I got it correctly but it still says that the value is not what was expected. What are you expecting?
It was thought to be a series of katas, starting very easy and getting a bit more complicated in the third part...