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!!!!
№ | Пользователь | Рейтинг |
---|---|---|
1 | tourist | 3993 |
2 | jiangly | 3743 |
3 | orzdevinwang | 3707 |
4 | Radewoosh | 3627 |
5 | jqdai0815 | 3620 |
6 | Benq | 3564 |
7 | Kevin114514 | 3443 |
8 | ksun48 | 3434 |
9 | Rewinding | 3397 |
10 | Um_nik | 3396 |
Страны | Города | Организации | Всё → |
№ | Пользователь | Вклад |
---|---|---|
1 | cry | 167 |
2 | Um_nik | 163 |
3 | maomao90 | 162 |
3 | atcoder_official | 162 |
5 | adamant | 159 |
6 | -is-this-fft- | 158 |
7 | awoo | 155 |
8 | TheScrasse | 154 |
9 | Dominater069 | 153 |
10 | nor | 152 |
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!!!!
Название |
---|
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.