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 couple notes here.
Number one, the naive way is MUCH more correct than this one. Most would just count left and right parens, and build the string with it. I choose to view this as a combinatorical problem with trees, and wound up not being able to finish it in time (mostly).
Number two, randomized tests are simply bad design. By resubmitting over and over, I was able to avoid the two numbers (9 and 10) which would choke this admittedly over-complicated piece of code. It's probably better, especially with problems that (at least CAN) scale exponentially, to have a static set of test cases. Even more so when the max input it ever sees is 10.
Third, while it's slow, inefficient, complex, and nearly impossible to read, this is one of my favorite pieces of code I've ever written.
Thanks!
It's matter of definition, and this kata defines
fib 0
as0
. As long as it's defined unambiguously, it's not a problem.To me,
fib 0 = 0
makes more sense thanfib 0 = 1
, because negative inputs work better ( more symmetrically ).Fib(0) is 1, not 0?