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.
I love it! Beautiful, even if it's in the same complexity class ;)
This comment is hidden because it contains spoiler information about the solution
@nuzyly Yes, you are completely correct.
The intention is better readable that way, but a comment would suit it better, I'd say.
Very nice, but let me ask:
PS: If the code would be used on a lot of URLs, it would save some load to call replace("-", " ") with the return statement, like so: return item.replace("-", " ");
and split the stream with "-".
The (Java) Kata provides an array of Objects, but does only provide Strings in it. This leads to a lot of solutions, that skip type checking and casting (if necessary) and thus reinforces bad coding habits.
So is it clever or best practice? :)
This comment is hidden because it contains spoiler information about the solution
I am new to JavaScript, so I am wondering if JavaScript does enforce semicola, or if the author of this solution was just lazy and the interpreter forgiving?
Without more information I guess it is hard to give any advise other than, insert some debug lines into your code.
In your first conditional
do{
n=n/10;
i++;
} while (n>0);
n is set to 0, as soon as it's done. Thus, when you want to extract the digits from n in your second do-while loop, you always get 0, trough the first and only iteration.
It is so interesting how many different ways there are to write code achieving the same goal, I really missed that in university. Great platform.
This comment is hidden because it contains spoiler information about the solution
https://www.codewars.com/kata/reviews/572a66baaa40be63e6000041/groups/578168a59fb2a5892c0001a9
Your solution is heavy on computational demand, scaling with n. I have found a solution scaling with the pattern length. Compare it if you are interested. :)
Loading more items...