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

    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, 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

    I was talking about this:

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

  • Custom User Avatar

    Any idea how to make that happen then?

  • Default User Avatar

    akar-0 is still right about random tests, though. they should "hold the fort" on their own.

  • Custom User Avatar

    A better solution would be to make random tests occasionnally generate such values, fixed-tests can always be hardcoded.

  • Custom User Avatar

    Could you give examples of codes that can pass all tests but fail on these ones?

  • Default User Avatar

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

  • Custom User Avatar

    Ok, should be fixed now! :)

  • Loading more items...