Debugging steps for WA/TLE problems

Hi all, Kindly share your insights on how do you debug the program(WA, TLE, App Crash). It will be really useful for us when we got stuck in solving a problem.

1 Like

For WA and RTE, I will think of some corner cases and also check with small cases manually.

  1. Explain your answer to a rubber duck. Some times you may find something helpful in this process.
  2. Try to break your code. (Some input that can cause variable overflow, divide by zero, infinite loop etc).
  3. Prepare worst case input, corner case input etc.
  4. Write an automated test case generator and if possible a checker. Now write a script that pipes the output of generator to a file. This file should be fed to your solution and checker and output of your solution should be piped to checker. Let it run unless your solution fails.
  5. If it is possible to prepare exhaustive test cases, generate all of them and test them.
  6. Output intermediate values for test cases and validate them.
  7. In case of crash, debug your code at the place of crash.