Qualified's blog

By Qualified, history, 4 years ago, In English

Many times, I get WA but don't know where to start when debugging, do you guys have a test case generator? Or something like that? Thanks!

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

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

I am not too experienced, but here are my two cents:

1) Think of corner cases that your solution misses — WA usually means you have missed an edge case. If it is a WA on an early test case (I get WA on test 2 a lot), then you can improvise a test case without having to spare too much time. 2) Otherwise, be creative. Try to think of something new — what you haven't thought of yet. If your mind is on a clean slate (you can't think of anything — this happens to me a lot), take a break. Try another problem (if you are in a contest).

Hope this helps!

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

Actually first i try to look at the constraints.Let our constraints be 0<=n<=100.Then i try to check with a test case where n=0.Also i try to check my whole code whether i have done a silly mistake.You can print the values of variables at several stages to check if they are giving anything wrong.Or you can use debuggers.There are some online debuggers like GDB.For TLE you can use test case generator to check your solutions with larger input.

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

I just read the WA code again and again and it works most of the times.

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

I only recommend doing this if you're in a pinch, but a stress tester can come in handy. Assuming the brute force version is trivial, test a bunch of small cases you can debug by hand and compare these two versions. I've only started doing this recently and it's already saved me on two separate occasions.

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

Search for corner cases Initially. If there aren't any corner cases, verify the solution once again. and at last, compare your solution with bruteforce for smaller cases.