What are the methods top coders use to understand the running of a code ?

Sometimes , the code you want to understand is too long / complex to run on paper. I would like to know how do you understand such a code .

Who runs code on paper? Looking at it and mentally linking the working of code is more than enough.

1 Like

Well, i agree with your opinion, but what do you do when you don’t find the code intuitive . Would you, for example, use a debugger ? I find 2-D DP problems especially hard to understand.

No. Use divide and conquer. Modularise the code, get it step by step. Usually it boils down to understanding 15-20 lines of logic and then things become clear. It comes with practice.

2 Likes

Documentation, hopefully.

1 Like

Well , i understand better with examples. That is , taking small input and seeing how it works out. Am I doing this the wrong way ?

Its also another way, but usually just having a look at the code sufficies for me on how it will react to that input. Checking variables and output is done for verification rather than hypothesis-framing

1 Like