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 | 4009 |
2 | jiangly | 3821 |
3 | Benq | 3736 |
4 | Radewoosh | 3631 |
5 | jqdai0815 | 3620 |
6 | orzdevinwang | 3529 |
7 | ecnerwala | 3446 |
8 | Um_nik | 3396 |
9 | ksun48 | 3388 |
10 | gamegame | 3386 |
Страны | Города | Организации | Всё → |
№ | Пользователь | Вклад |
---|---|---|
1 | cry | 164 |
1 | maomao90 | 164 |
3 | Um_nik | 163 |
4 | atcoder_official | 161 |
5 | -is-this-fft- | 158 |
6 | awoo | 157 |
7 | adamant | 156 |
8 | TheScrasse | 154 |
8 | nor | 154 |
10 | Dominater069 | 153 |
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.