Ad
  • Custom User Avatar

    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.

  • Custom User Avatar

    Unlikely.

    Please read the docs on how to debug your code, and how to raise Issues 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.

  • Custom User Avatar

    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

  • Custom User Avatar

    it's less than zero

  • Custom User Avatar

    You are passing a negative value into charAt() in this line of code.

            array[boxes]=String.valueOf(s.charAt(2*boxes));
    

    ...so it is going to crash for sure if you keep doing that

  • Custom User Avatar

    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)