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 just checked your code (your current solution that is visible at least) and it seems to pass all the tests to me?
So it seems tests are OK - maybe you were reading logs incorrectly: the error message always appears below any console output for that given test so here you were probably reading the results for the previous test with
n = 23
which expectsFalse
?My piece of of advice:
Don't get down because of other people's solution, because no matter your skill level it is very likely that someone else could do better than you! I enjoy reading other people's solutions and regard that as my reward for solving a kata.
As a general introduction to coding and problem solving I recommend Prof. Peter Norvig's free online course (you can easily google it), the lessons and exercises will teach you to reflect on your solution strategy.
Take your time and practice, and make sure you learn the in and outs of your preferred language, so that you can focus on problem solving.
Good luck and happy coding!
I'm not a great coder (just adding that up front), but I have used the Kata to get better (I think, and hope). My approach is to solve the problem however I can. Once I have code that is good enough, I go back to it and see if I can tidy it myself. If not, fair enough. Submit, and then I read other solutions.
For the other solutions I read and try and udnerstand them. I try and work out a the solution seems to be showing off (just trying to use the least lines of code for reasons I don't understand), or if they are doing something I would like to learn.
If a solution is doing something I want to learn I may try and use that on the next kata, or just go and read up on it.
Every so often I go back to solutions I wrote long enough ago that I think (hope), I am know significantly better. I then try rewriting with my current knowledge. I leave it awhile because if I have just learnt something new from another solution and try using it, chances are fi am just copying someones elses approach, not really understanding and applying it.
First of all, you have to be careful when judging other solutions as "neater". The fact that they are shorter, have fewer lines, use some built in functions, or have many upvotes, does not even mean they are good. On the contrary, quite often short solutions to white kata are very poor, for example in terms of performance.
But that's true that beginners ofter reinvent the wheel while some solution to the problem exists, and portions of the code can be replaced with a call to library function. There's no other way to learn how to use them other than getting more experience. You are on a good track solving kata, just solve more, then even more, and every time look at other solutios and try to understand how they work.
Yep, it's not good enough. There's a little trick you need to figure out to speed up the process, which makes it harder than your average 7kyu, IMO.
You're probably missing some
return
statements. You might wanna google around to see how to do recursion.