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.
Now I see what the problem was. I'm not a Java guy, but you should really stay away from using static variables (unless you know what you're doing), define them in function body instead.
Anyway, at least you solved it.
Are you using recursion? It could be printing multiple values for single test in that case. There's no need to log values towards the end, because you'll see in console what was expected, and what you submitted.
Anyway, this is getting us nowhere. Could you post a screenshot of what you see when the tests fail? Or post your code here using proper markdown as
@Chrono79
mentioned above.Maybe, when you use global vars and don't reset their values, it works fine the first time, but then it carries the last value and when called several times it produces wrong results.
Yes it helps (but I'm only interested in initial values right now). So could you tell me what's the initial n, expected result and your result, for the failing test?
Are you using some global var maybe? Post your code with proper markdown and mark your post as having spoiler content.
No... You need to know the initial value. Then you can reason about how it reaches expected result, etc. Logging it at the end can be useless, depending on what you're doing with that value.
With n = 0, correct solution should be 0, that's correct... Are you logging at the beggining of the function? Try to see what console outputs for n when the test fails.
Btw, I solved this myself and I can assure you the tests are correct. Let's figure out where exactly you're failing.
It's because the input isn't 0. That's the
EXPECTED
result. To see the input, log it usingSystem.out.prinln(n)
. Without input, I can't help you, but I'm 99% sure that the problem is in your code, and not the kata itself.Btw: Java Completions 9737. Are you saying all of them wrongfully solved this? :P
What is the language? Print the input, then compare with expected result, and if you still think it's wrong, ask here why.
This just means your function returned 9, when the test was expecting 0. (you didn't tell us what the input was, so that information has little value :/)
It could be that the test suite fails and doesn't continue once it gets wrong result, so it's probably not the last test.
The kata has thousands of solves, and your code returning wrong result is not a KATA issue, so I'm closing it. If you want further help, post a new question with more details as I outlined above.