When submitting a solution in C++, please select either C++14 (GCC 6-32) or C++17 (GCC 7-32) as your compiler. ×

harsh1919's blog

By harsh1919, 3 years ago, In English

Hello everyone! I am a beginner in CP and I recently started practicing in Codeforces and Atcoder. So I had this question for a while; Is it bad practice to see failed test cases instead of figuring that out by myself since during actual contests we cannot see that. So I want advice from you guys regarding this because I don't want to get accustomed to bad habits.
Thank you!

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

| Write comment?
»
3 years ago, # |
  Vote: I like it +50 Vote: I do not like it

its better to dont see the testcases, but its not really important

»
3 years ago, # |
  Vote: I like it +6 Vote: I do not like it

For my personal opinion , if you think you have tried your level best of the problem but missing some simple corner cases while practicing then you should see the test cases(except sometimes you may face infinite query in test case).The reason is staring at the problem and your approach won't help you much, and it may lead to depression and waste of time which is very bad for cp. And of course it's a bad practice to see frequent test cases but you should know when to give up and go on.

»
3 years ago, # |
  Vote: I like it -17 Vote: I do not like it

It's a good practice

»
3 years ago, # |
  Vote: I like it -15 Vote: I do not like it

Actually not, because for me it costs much time to find where to debug than generate thousands of testcases and debug with that, even when i do contests

»
3 years ago, # |
  Vote: I like it +65 Vote: I do not like it

Being able to figure out what is wrong with your code without looking at test cases is a skill that you will develop over time. When I started out, I would look at test cases whenever I got really stuck trying to find the bug in my code. Nowadays, I'm almost always able to fix my code without looking at the tests. I'd recommend the same approach for beginners: it's okay to look at tests right now if you get really stuck trying to find a bug; over time you should get better and better at finding bugs on your own and accordingly be more strict with yourself about not looking at tests.

Also remember that you can always generate your own tests to run your code on -- this doesn't always work, but sometimes it will (and it's possible to develop a sense for when it might help you find a bug) and you can do this during contests too.

»
3 years ago, # |
  Vote: I like it +6 Vote: I do not like it

I think that initially you should try to find the error without looking at the testcases. But if you are really stuck (that means usually it is a hard problem to you), I would say it is ok to look at the testcases.

»
3 years ago, # |
  Vote: I like it +12 Vote: I do not like it

Guess that’s why I don’t have a higher rating...

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

I am not sure but I usually look up the test case if its possible to see because there may be chances that I am solving the problem in wrong direction considering that to be correct. You can then think of another approach and hence can save time.

»
3 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Well in my case, I try to debug with different test case but when I feel like I have tried my best but not able to find that case then it's better to see test case.

»
3 years ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

From my point of view it's little bit of bad habit but consider these points : 1 — after getting (WA || TLE) read question again and read the constraint again and walk a little while thinking it may happen that some another approach strike; 2 — start making test cases by our own by keeping constraints in mind. the best advice on how to make own test case is think someone else has written code and your task is to hack its solution by giving the worst test cases; (give testcases that can be calculated manually also so we can be sure about the answer) 3 — after spending an 1/2 hour and covering the above two point if still stuck then just see the test case.

note : always try not to see test case as much as possible as that one bit of more thinking to get accepted is always more better then to see testcases and gets accepted;

hope it helps && happy coding.