Manoj07's blog

By Manoj07, history, 6 weeks ago, In English

Hello, Codeforces community

I need your advice on how to get the logic from the code. Since most of the time, we first given the logic and then introduced it to the code. But here, many times, I face issues on understanding editorials; hence try to do a dry run of the code either from successful submissions or from the editorial. But some codes use such a large number that I can't do a dry run. Hence, seeking help for the same. I also appreciate it if someone shares their experiences about how they build the logic for a problem.

I really appreciate any help you can provide.

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

6 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

Use Thonny(best for debugging code) if you know python!

6 weeks ago, # |
Rev. 3   Vote: I like it +14 Vote: I do not like it

Bad news friend. You are doing it wrong.

You don't reverse engineer the logic from the code unless you are familiar with the patterns/strategies that are being used in the code (e.g. you can recognize a well known algo from the author's code).

You should be trying to understand the author's logic first before looking at his code. Better still if you can use the logic to write code of your own (and maybe look at the author's code for hints along the way). This is what will help you improve.

If you cannot even understand the logic to begin with, then the problem is too hard for you. Try an easier one.

  • »
    6 weeks ago, # ^ |
      Vote: I like it +27 Vote: I do not like it

    I've used reverse engineering to get better when I was div2 so I don't see it as that wrong. I can agree with trying to reverse engineer the process (step by step with a debugger for example) instead of the logic being wrong.