Ad
  • Custom User Avatar

    Ty for putting up with me =P

  • Custom User Avatar

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

  • Custom User Avatar

    I am not concerned with the randomised testing!
    There is a discrepency between real test results, and the results given by codewars, even though the code, and the tests are the same, as evidenced.
    (Eclipse unit tests pass, codewars unit tests fail. Same code. Same tests.)

  • Custom User Avatar

    Image of Failed Unit Tests

    (May need to right-click -> open in new tab)

  • Custom User Avatar

    I am aware that the three basic tests work with my code, however the tests do not pass within the online environment

  • Custom User Avatar

    Can confirm it is JUnit from Eclipse that is telling me that the Basic Tests are working

    Image of Passed Unit Tests

  • Custom User Avatar

    Here are the tests:

    assertArrayEquals(new double []{1,1,1,3,5,9,17,31,57,105}, variabonacci.tribonacci(new double []{1,1,1},10), precision);
    assertArrayEquals(new double []{0,0,1,1,2,4,7,13,24,44}, variabonacci.tribonacci(new double []{0,0,1},10), precision);
    assertArrayEquals(new double []{0,1,1,2,4,7,13,24,44,81}, variabonacci.tribonacci(new double []{0,1,1},10), precision);

    You can see the parameters where n==10.

  • Custom User Avatar

    I haven't made any modifications past what I have already provided, so that is my current code.
    I could do that, and it would probably work, but that doesn't solve the issue that we can't seem to solve :/

    I misread. All of the basic tests are n==10, not 3 and therefore should not get caught in the infinite recursion part of my program, and therefore should work.

    The fact that the basic tests work offline, but then fail online, with exactly the same code is the part that is my issue. Yes changing the code will fix it, but the code I have already provided doesn't seem like it should be behaving this way...
    Would it be possible to get this marked as not resolved, and then if anyone provides an answer at a later date that explains this strange behaviour, it can be marked as resolved?

  • Custom User Avatar

    Ok yes, in the randomised tests, 0 <= n < 3. I will admit that my approach does not work for those tests.
    But it is still failing on the basic tests, which I have done separately, and have confirmed to work. (n==3)
    And there are still randomised tests where n > 2, yet still fail...
    How are the stack overflows being caused in these cases?

  • Custom User Avatar

    N will never be less than 3, by definition of the problem, therefore handling those cases is outside of the scope of the kata.
    And it doesn't matter that I implemented my solution slightly differently than suggested, it's only the result that matters, and the correct results are produced, as shown using the separate IDE.

  • Custom User Avatar

    That is not what I am saying in the op!
    The code WORKS!
    I wrote it in a separate IDE (Eclipse) and ran it against the provided unit tests. The unit tests all passed.
    Yet, when pasted into the online editor, I get a stack overflow error, instead of the correct result.
    Does codewars provide a smaller amount of heap than a standard compiler? Because then the large numbers of stack frames may cause it to throw the stack overflow exception? All though my other recursive solutions do not behave in this way... :/

  • Custom User Avatar

    I ommited the class declaration and imports. They're there. If they weren't, Eclipse wouldn't have passed the unit tests, but like I said, it did.
    I only included the method, as I thought people would be able to realise... :/
    Also, I did mark it as a spoiler, but then I edited it, and I must have forgotten to turn it back on. That one is my bad...

    If somebody else could copy and paste into the Kata to check my method, and my sanity, that would be greatly appreciated
    You will need the import: import java.util.*;
    (Not the best practice, but it will work ;P)

  • Custom User Avatar

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