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.
ez
See my fork for a simple, clear, non-recursive solution to this, using a bit of abuse of default input to shorten the solution. I prefer that a lot over putting
if/else
statements on a single line though.You can always just turn recursion limits off too (which also works here on codewars!)
Yeah I agree if it were to be used in the real world it would probably be better and safer to do it iteratively and do some checks so it doesn't run forever. For these small kata I find it more fun to solve them in short and interesting ways though :)
I think recursion may be a little risky here, as the max recusion depth may be reached for strange values of n.
wow!
polymorphic recursion :)
I personally like this solution because it reads easily and you can see exactly what is happening.
the cut == 0 check is not actually required here because n*(n+1)/2 will equate to 0.
Assigning self.other_name is possibly not a great idea as this variable is not being used by any other methods in the class.