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.
Thank you =D
Good answer, but the formatting needs some work. The variable names should be descriptive, and the return value should get its own line.
I like the clever use of the or statement to catch the out of bounds indexing of the array. I made a slice instead, but I suspect your solution is faster. Nice one!
Nice solution. One small tip, you can use [string, string] as the return type for capitalize if you want to be more specific. This will only accept an output array of two strings.
Cheers!
Good kata. I do feel like it is probably a bit too difficult for 7kyu. This feels like a 6kyu kata to me. The newlines in the input string in particular is something I have seen very little of on codewars and I see in the comments that it seemed to throw many people for a loop.
You probably already know this, but for others looking at solutions, shifting an array takes O(n) time because it requires updating the index values of every element in the array, where as poping the end of an array takes constant O(1) time. So it is best to pop vs shift whenever possible.
Cheers!
This should be voted the best practice. This answer has O(1) time complexity for lookups vs O(n) used in the higher ranked answers. Nice job.
This comment is hidden because it contains spoiler information about the solution
I love how concise and readable this answer is. Having said that, this problem can be solved in a significantly faster way. Each sort operation is θ(n log(n)) time plus it looks like a1 is iterated over 3 times and a2 twice then both are compared. You can solve the answer with iterating over a1 once, a2 once, then comparing =)
Cheers!
Beautiful.
This has a glitch in it that is not caught by the kata test cases. Taking the absolute value of num for every entry will throw false positives for negative input numbers. For example day = "Monday" and num = -12 with return true when it should be false.
Nice solution ;)
While it does work, formatting like this should be avoided as makes the answer much harder to read.
Oh this is really great! Nice one.
This comment is hidden because it contains spoiler information about the solution
Loading more items...