gkeesh7's blog

By gkeesh7, 10 years ago, In English

Greetings Everyone, It's just one of those days when I feel too lazy to solve any problems on Codeforces but don't feeling like doing anything else either. In the past few contests I have been annoyed by bugs which result in WA/TLE etc and wanted to know is there any systematic approach to problems testing in competitive programming which can be applied to remove bugs, that too in an intense pressure situations (like ICPC). Because most of the time while I am testing some bug in my implementation, I throw random testcases at the solution and expect it to fail and incase it does I consider myself really lucky. I would like to ask all the experienced guys about any tips/tricks/tools for testing the solutions which they would like to share.

So far after messaging some people the valuable tips that I have received include

(text in italics are excerpts of actual messages received)

1) Reading the problem statement carefully

(not so valuable but still important :)

2) Emphasize on constraints of the problem

"test on atleast one maxtest"

3) The tricky base cases

"zero in most of the cases is tricky but at times other numbers may also be you can't possibly generalize"

4) Learn to use gdb or any debugger

"if you keep adding printf/cout statements to check value of variable in each iteration not only that is time consuming but also looks unprofessional learn to use Gdb also modify your template with some cerr messages as I can see there aren't any:)"

5) Generate your own maxtest

"i generally use python to generate my own maxtest file which is cool considering it takes only 5-10 lines of code"

Some of the questions which want to ask include

Do you use some generators etc ? If yes which ones ?

What are your thoughts while writing a manual test for the code ?

How are you able to keep yourself calm incase of a wrong attempt ?

Feel free to share any ideas/tips/tricks in the comments section below.

[ UPD ] Some of my friends have told me to ask the following questions to guys who have experience at writing system tests at codeforces or any other platform.

1) What do you guys do to ensure the completeness of the test cases ?

2) What do you guys consider while writing the maxtests ?

3) Do you classify your tests in categories like Pretests , Easy , Overflow possibility , TLE possiblility , Random cases, Not initialized variables will fail, Tricky basecases, Chances of accessing invalid memory address etc ?

  • Vote: I like it
  • +13
  • Vote: I do not like it

»
10 years ago, # |
  Vote: I like it +22 Vote: I do not like it

6) if the problem contains multiple testcases in one input file then make sure that you initialize all your variables and arrays before computing the answer for each test case.

  • »
    »
    10 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Thanks, I remember initializing my ans variable with -1 once to find the max element of an array not realizing that there can be possibly none selections at all from the array, it should have been initialized to 0. Pretests were passed, I got WA on the main tests :(