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.
A reasonable optimizing compiler will produce the same machine code regardless of whether the variable is defined before the if-check or after it. Initializing local variables has no effects visible to callers so the compiler may freely reorder the code as it sees fit.
The reason is just style and clarity. First of all, it's common to add preconditions to the start of a function. If there are no items, we already know the answer and we can return right away. Second, it's generally a good idea to keep the scope of variables as small as possible.
Of course, in such a short function it doesn't really matter, but if a long function defines variable in the very beginning and uses it a lot later, can you be sure that there are no uses between? You have to carefully read through the whole function to check if there are other references.
This comment is hidden because it contains spoiler information about the solution
Done.
Random Tests included.
How could i make recursion obligatory?
Fixed.
.
This comment is hidden because it contains spoiler information about the solution
Don't know why the system marked this as an issue. I said it's a suggestion…
This comment is hidden because it contains spoiler information about the solution
More test cases (especially hidden ones)
Thanks for the input! :) It's my first Kata and I'll try to get it done
Finally a recursive solution ;)
+1 yes - please get some documentation up for C#! Even is it is a rough and ready brain-dump!
Loading more items...