Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
.
Why is this not considered best practice?
Approved
Exactly, that's why even I am struggling to understand.
How is this best practice?
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
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.
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.
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. ;)
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.
@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.
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...
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?
I was talking about this:
I'm rather new to codewars, but I suppose the author can update the kata if they approve?
Any idea how to make that happen then?
Loading more items...