Rakib_32's blog

By Rakib_32, history, 5 months ago, In English

Hello Coders,

It may seem trivial, but I'm here to seek your valuable advice on writing code with minimal bugs. Currently, I find myself spending more time debugging my code (often for silly mistakes) than I do coming up with the solution and coding it. I've been struggling with this for quite a while and am eager to know if anyone else has faced this challenge and how they managed to overcome it.

Thanks in advance!

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

»
5 months ago, # |
  Vote: I like it +19 Vote: I do not like it

Hi Rakib_32, I have the same problem too, but the following points helped me:

  • When you practice or upsolving before coding you can do pseudocode in paper
  • Try to concentrate hard like a chess game when you write your code (I used to play chess :D)
  • When you practice and got struggled with implementing a problem, after getting AC you can try to code the same problem again in less time (also see others code)
  • Analyze and be careful with common errors for you, for example I noticed when I change a 'for' from 0 to n-1 to a 'for' from n-1 to 0 forget to change the 'i++' to 'i--', it happened to me several times and lose so much time debugging, so now I'm very careful in that situation.
  • In hard problems for me, I like to add break lines to divide logic also add some comments, like this submission https://codeforces.net/contest/1977/submission/262769673

I hope it can help you too, but remember each one is different and can help you with different things, good luck! :)

  • »
    »
    5 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Love your sense of humor

  • »
    »
    5 months ago, # ^ |
      Vote: I like it +21 Vote: I do not like it

    A big us to the fourth point. Thanks for sharing your valuable insights. I will try to follow along.