Ad
  • Custom User Avatar

    .

  • Custom User Avatar

    Why is this not considered best practice?

  • Custom User Avatar
  • Custom User Avatar

    Exactly, that's why even I am struggling to understand.

  • Custom User Avatar

    How is this best practice?

  • Custom User Avatar

    Why would adding a fixed test not be a solution? Of course you can calculate the probability that this edge case is generated by random tests and then add enough random tests to guarantee a 99.9% chance of covering the edge case, but honestly just adding a fixed test and calling it a day seems like the reasonable solution here.

    According to the codewars docs, this is exactly what fixed tests are for: https://docs.codewars.com/authoring/guidelines/submission-tests/#fixed-tests

  • Custom User Avatar

    Ok, I misread you. Though, adding a single test is not a solution, it's easy to hardcode it, the solution would be make sure random tests generate values making this code fail, but, like I was saying, I'm not sure your wrong approach is sufficiently common to consider it's an issue for the kata.

  • Custom User Avatar

    Your solution being buggy and needing a special check to pass the tests is not a kata issue

    I may not have been clear. My solution passes even though it is wrong because the tests dont verify all cases. It does not need extra checks to pass. There should be extra tests because it shouldn't pass. At least that's the point of tests, to make sure that wrong solutions are not accepted.

    It's hardly possible to make tests able to catch all the kinds of minor possible mistakes.

    In this case that's not very difficult since I propose the extra test in my original comment. It's a matter of copy/paste and you have one less bug. ;)

  • Custom User Avatar

    Your solution being buggy and needing a special check to pass the tests is not a kata issue, unless you demostrate a significant number of other solutions have the same problem. It's hardly possible to make tests able to catch all the kinds of minor possible mistakes.

  • Custom User Avatar

    @najamelan: in general, fixed tests don't aim to catch edge cases. They aim to help the user control his code with a certain number of representative values so he can debug it more easily and improve it. When there are a great amount of possible edge cases, like here, using fixed tests is definitely not the right way to do. Though, it may be a good idea to add the examples you give as fixed tests, but it's not enough.

  • Custom User Avatar

    With 300 tests like we have here it's possible to make tests that will generate a certain number of those 3 cases with an extremely high probability (with 99.9%, that would mean a user would need to subm,it a wrong code about 1000 times for it to pass... ok. We're talking about a relatively basic 7 kyu...). Still if you are paranoid, it's also possible to make it sure. It's just a bit annoying to write...

  • Custom User Avatar

    It they are random, you can never guarantee all edge cases are covered. You can say we want 99.9% chanche this edge case occurs. Then you can calculate how many random tests you need to achieve that. It will never be 100%. Or you can simply add some fixed tests to make sure it's covered. Why would kata's have fixed tests otherwise?

  • Custom User Avatar

    I was talking about this:

    A better solution would be to make random tests occasionnally generate such values

  • Custom User Avatar

    I'm rather new to codewars, but I suppose the author can update the kata if they approve?

  • Custom User Avatar

    Any idea how to make that happen then?

  • Loading more items...