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.
This kata is 3 kyu for a reason.
Your code needs to be optimised. The fact you can't do that is not a fault of the kata.
Unlikely.
Please read the docs on how to debug your code, and how to raise
Issue
s after you've made very sure it's not actually your code that has the problem.Closing now, please reraise after you've read that, in a more useful manner.
you can stare at your code and think about what it means, you can use print statements to see what that value is at any point, but it's up to you, and you should be able to figure out how you have given your variable its value
it's less than zero
You are passing a negative value into
charAt()
in this line of code....so it is going to crash for sure if you keep doing that
The problem is you're trying access a string by index, but using a negative index, which is not possible.
When you make such a change, the error message you get changes because a different test is being affected.
(if length is 5, then length - 1 == 4 ... index within bounds)
(if length is 0, then length - 1 == -1 ... index out of bounds)