Ad
  • Custom User Avatar

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

  • Custom User Avatar

    hi thnks for pointing to the >>> myJourney issue...
    i fixed it already...

    as for 'testAssertContains' i dont understand what you are asking for... as BOTH the
    Test.assertContains(Journey(5, "Dalston", "Crystal Palace"), "YES! You can make it! You will have £2 left on your card.");
    Test.assertContains(Journey(1, "Dalston", "Crystal Palace"), "NO WAY! Top-up £2 or more for this journey.");

    test cases contain the full string with the correct integer (credit remain on card when YES ... OR the amount missing (top-up) + full string sentence)...

    do you mean that i shall change Test.assertContains >>> to contain less? like "YES you can make it" AND "NO WAY!" ?
    OR do you mean that i shall change >>>
    Test.assertContains(Journey(5, "Dalston", "Crystal Palace"), "YES! You can make it! You will have £2 left on your card.");

    TO >>>
    Test.assertEquals(Journey(5, "Dalston", "Crystal Palace"), "YES! You can make it! You will have £2 left on your card.");

    sorry to ask this but i validated all test cases and they all come back as green. please explain what you think the problem is. and waht could be the solution.

    thank you.
    z

  • Custom User Avatar

    Hi Zoltan, nice Kata idea, but there are some problems: the tests should be 'testAssertEquals' and what the code has to return written out in full, or at least 'NO!' should be replaced by 'NO WAY!' in order for 'testAssertContains' to work with the requested return for a negative.

    I think something is wrong with your test code, also, as when I try to test I get the error 'Journey is not defined'. You should check your code to make sure you've not got Journey instead of 'myJourney' somewhere, perhaps?

  • Custom User Avatar

    The description is hard to read and misleading, e.g. you write you need to create your own map but all I need is the two dimensional array that's passed as the first argument.
    Or you write each zone will cost you £1 more to cross which I read as "it costs 2 + 3 + 4 + ... = (n + 2) * (n - 1) / 2 to travel from zone a to zone a + n" but instead it's just "n + 1".

    The solution setup has unneccessarily an array stations and a function call myJourney(stations, 5, "Dalston", "Crystal Palace");. Remove them.

    The tests use assertContains which IMHO is an invitation to cheating.
    Better be specific about what you expect, e.g. "return a string 'YES! You can make it! You will have £xxx left on your card.' (where xxx is the amount of credits left after paying for the ride) OR 'NO! Top-up £xxx or more for this journey.' (where xxx is the amount of additional credits needed for the ride)."
    Then testing becomes a lot easier.

    Also, the random tests are commented out.

    Currently this kata looks half-baked. I suggest you un-publish it and improve it in 'Draft' state or you will get a lot of negative votes.

  • Custom User Avatar

    ok.

    i might just come up with a new idea than.

    thanks
    z

  • Custom User Avatar

    As mentioned below, it's a duplicate.

    Also, trailing new line is not specified.

  • Custom User Avatar

    i dont mind if it's simple
    they dont have to be hard...

    how can i find out if it's a duplicate?

    z

  • Custom User Avatar

    ok i managed to find the JavaScript test framework...

    https://github.com/Codewars/codewars.com/wiki/Codewars-JavaScript-Test-Framework

    will use this and fix random tests...

    thx.
    z

  • Custom User Avatar

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

  • Custom User Avatar

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

  • Custom User Avatar

    Random testing not implemented. But really, don't bother. Too simple and too probably a duplicate.