• Custom User Avatar

    Hey BobBash

    Your solution would work for the kata: http://www.codewars.com/kata/steps-in-primes/java but here you have to keep in mind that if there is another prime inside the gap, then the result is not valid and you have to look further.

    Hopefully this helps you out a bit.

    Cheers

  • Custom User Avatar

    well, as I mentioned before, I added the below tests and code finished in 140ms..

    Test.assert_equals(gap(2, 10000000, 11000000), [10000139, 10000141])
    Test.assert_equals(gap(84, 432560923690632432, 93274782356043246324324), [432560923690633109, 432560923690633193])


    now I added these two, 524ms to finish
    Test.assert_equals(gap(84, 43256092369069327478235604324632432432432, 9327478235932747823560432463243246043246324324), [43256092369069327478235604324632432439529, 43256092369069327478235604324632432439613])
    Test.assert_equals(gap(84, 4325693274782356043246324324092393274782356043246324324690632432, 932932747823560432463243247479327478235604324632432482356043246324324), [4325693274782356043246324324092393274782356043246324324690634993, 4325693274782356043246324324092393274782356043246324324690635077])


    still think my code won't finish within 6seconds for whatever is the given tests?

    I just don't know what is happening

  • Custom User Avatar

    Don't take the habit of putting an issue before knowing it's a problem of your code or of the kata:-)
    Tell me when you succeed!

  • Custom User Avatar

    Thank you, I sorted my problem out, just running out of time now, so I need to optimize.

    Running through up to and including Test25. So just the last 3 tests to conquer.

  • Custom User Avatar

    It is posible to do all test cases under 200ms (in JS). So try to write more efficient algorithm. Good luck.

  • Custom User Avatar

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

  • Custom User Avatar

    Thanks for your time! The test 21 is:

    assertEquals("[[4500001, 2250000], [73801, 36870]]", Dioph.solEquaStr(9000001));
    

    Maybe you can post your solution (mark it as Spoiler!). I will try it.

  • Custom User Avatar

    Lots of Codewarriors passed the Java kata. As usual I tried my solution and a few others without any problem! The fixed tests and the random tests are built exactly the same way with Arrays.toString... Did you think to return null when necessary? I find that you are very unlucky with my katas:-(

  • Custom User Avatar

    In Java, in both the "Run Test" and "Submit" I get the same problem, the Arrays.toString() passes the address pointer, not the contents as string.

    When I submit, the Fixed Tests give the problem, but the 100 random tests are all successful.

    test(GapInPrimesTest)
    Fixed Tests
    expected: but was:<[J@1fa21536>
    test1(GapInPrimesTest)
    100 Random Tests
    Test Passed
    1 Passed
    1 Failed
    0 Errors
    Process took 3551ms to complete
    

    Any solution for me?

    BTW: a nice chalenge, with a fast solution depending more on logic than calculation.

  • Custom User Avatar

    The 3 backticks are "```" (google "markdown" if you don't know). On a newline put the 3 backticks, then a newline, then your text, then a newline, then once more the 3 backticks and a newline... I ask you for that because it could be a problem with white spaces and in normal text they can't be well seen. Put completely, for only this test 21, what you got in the CW console.

  • Custom User Avatar

    I didn't remember about what I saw you:-(
    I'm very sorry but all the tests have the same format as said in the description:

    "[[x1, y1], [x2, y2] ....]"
    

    left bracket left bracket number comma white-space number right bracket comma white space left bracket and so on...
    Test 21 has exactly the same format as the other ones.
    Could you give between three backticks what you get when a test fail? (only one example!)

  • Custom User Avatar

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