Ad
  • Custom User Avatar
    1. Change digital_root(spezial) to return digital_root(spezial). You need to return the value and you are simply calling the function. Once the function has been called, there is no statement to return and retain the value; therefore "undefined" is returned (default value).
    2. Make sure you put a variable declaration name next to your variable. In your for loop, put var before the variable i. This doesn't effect this code, but makes the variable global which may affect your coding in the future if you don't include it (I've seen bugs before because of the lack of it).
    3. Use markdown to format your code - see here https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet#code-and-syntax-highlighting.
  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    I've left the issues open because they haven't been resolved. The author hasn't been on since February, so the author may fix it in due time. It gives you notifications if there is an issue, so the author can look at them when they get back; your comment wasn't marked as an issue so it's less likely that the author may see it also.

  • Default User Avatar

    thanks for the answer. i'd already seen your reply in another comment but as tests aren't fixed yet i think it's good to relance the issue...

  • Custom User Avatar

    I'm quite confused by your comment. You might be using the coding structure wrong? You don't have to implement testcases since the Kata already has inbuilt testcases.

    Mind if you post your code to this reply so I can see what's happening?

  • Custom User Avatar

    You're meant to return the final output, not print it to the console. Returning the value allow the yields the value, meaning the function call retains this value. The output can be checked for equality using testcases.

  • Custom User Avatar

    Read the comments next time.

    In the Java testcases, the expected and the actual are swapped around, so your solution is returning 0 and the expected answer is 7.

    Proven by the testcase

    assertEquals( "Nope!" , DRoot.digital_root(16), 7);
    
  • Custom User Avatar

    I get this result in the Python version as well.

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    Yes, this code is inefficient.
    My javascript code with non-optimal solution: Time: 412ms
    My javascript code with optimal solution: Time: 301ms
    My java code with optimal solution: Time: 42ms

  • Default User Avatar

    Java: 16 expected 0 but it is 7. I am pretty sure it should be 7