Hello Everyone, I would like to know the process from which you come up with various edges cases(test cases) during live contest to check the correctness of your code?? Also plz suggest some practices, if any! Thanks a Lot!!!!
# | User | Rating |
---|---|---|
1 | tourist | 3985 |
2 | jiangly | 3814 |
3 | jqdai0815 | 3682 |
4 | Benq | 3529 |
5 | orzdevinwang | 3526 |
6 | ksun48 | 3517 |
7 | Radewoosh | 3410 |
8 | hos.lyric | 3399 |
9 | ecnerwala | 3392 |
9 | Um_nik | 3392 |
# | User | Contrib. |
---|---|---|
1 | cry | 169 |
2 | maomao90 | 162 |
2 | Um_nik | 162 |
4 | atcoder_official | 161 |
5 | djm03178 | 158 |
6 | -is-this-fft- | 157 |
7 | adamant | 155 |
8 | awoo | 154 |
8 | Dominater069 | 154 |
10 | luogu_official | 151 |
Hello Everyone, I would like to know the process from which you come up with various edges cases(test cases) during live contest to check the correctness of your code?? Also plz suggest some practices, if any! Thanks a Lot!!!!
Name |
---|
My motivation: https://youtu.be/tZQkpxgXSGg
Believe me it works
I only had 1 downvote.
A good way to deal with edge cases is to have as little of them as possible.
For example, when you come up with a general solution, check it on some examples by hand. Importantly, check it on the minimal possible examples. For an inspiration, see constraints for the problem, and just plug in the minimum values as input.
Often, the solution won't work on these examples. What to do, what to do?! I know: let's just consider them a special case, patch them up, and our solution will work! Right? Wrong.
A more productive mindset is to see why the solution fails, and find a bug in it. Remember, the example you used is very short, so checking each step of the solution should be trivial. The bug can be an implementation error, or it can invalidate the solution idea. Either way, a test case with a wrong answer is an opportunity, first and foremost. If you patch it up as a special case, the probable bug remained, you just made it one case harder for yourself to find it again.
Sometimes the minimal possible inputs, or other tricky inputs, are indeed special cases. Mark them as such only when you followed your solution through, understood why it doesn't work for them, and importantly, refined your knowledge about the domain where the solution does work.
Thank U !!
I prefer to write a brute force approach and generate random test cases and break the loop whenever my answer and answer from brute force method does not match. You can easily print them and then look up for the mistakes in your program. Generally brute force method codes are easy to implement. So if you are unable to figure out the mistake on your own and you know the brute force approach, then quickly code it and print the input whenever the answers don't match.