How do I dry-run my code?

Modified on Tue, 28 Mar, 2023 at 4:39 PM

Why to dry-run?

Dry running a code involves manually executing each line of code in order to understand how the code works and what output it produces for a given set of inputs. This process is useful for debugging and identifying issues with the code.

How to dry-run?

You can follow these steps to dry-run:

  1. Come up with base cases and edge cases (input and expected output). 

  2. Take one test case at a time and use pen and paper or an editor to step through each line of code and note down values. See if your code can give you the expected output.

  3. You can also try to run your code with these inputs and use print statements to see the modification of values when your code executes.

  4. This might be a time-consuming process but it will help you find out where your code is failing. 


Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article