Ad
  • Custom User Avatar

    The text not having a comma after the second name messed me up, but after editing those out of my code I got it to pass.

  • Custom User Avatar

    I'll take another look, thanks so much for the speedy reply. It shows my naivete that I didn't know the stack trace was that helpful in debugging. Thank you!

  • Custom User Avatar

    I changed the tests a bit in an attempt to make the failure messages clearer. They look better now, but I wonder if clear enough.

  • Custom User Avatar

    It is unfortunately JUnit giving not very clear feedback in some situations, but the root cause of the error is in your code. Look at the stack trace:

    java.lang.NumberFormatException: For input string: "813611416183156161"
    	at java.base/java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
    	at java.base/java.lang.Integer.parseInt(Integer.java:652)
    	at java.base/java.lang.Integer.parseInt(Integer.java:770)
    	at SquareDigit.squareDigits(SquareDigit.java:29)
    	at SquareDigitTest.test(SquareDigitTest.java:7)
    	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      [... snip ...]
    

    in the line 4th from the bottom you can see that the error comes from the Imteger.parseInt, which is un turn called from SquareDigit.squareDigits, i.e. your solution. You have a bug in your code, which paired up with the poor test feedback.

  • Custom User Avatar

    In Java: When using the sample test, it keeps failing but failing on a string as input? The kata says only accepts and returns an integer. Do I need to be cleaning the input? Text from the error here: Test Results:
    SquareDigitTest
    test
    For input string: "813611416183156161"

    I am pretty new to CodeWars, I am returning an integer via return, not print.