Пожалуйста, прочтите новое правило об ограничении использования AI-инструментов. ×

Блог пользователя Rakib_32

Автор Rakib_32, история, 3 месяца назад, По-английски

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!

  • Проголосовать: нравится
  • +20
  • Проголосовать: не нравится

»
3 месяца назад, # |
  Проголосовать: нравится +19 Проголосовать: не нравится

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.me/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! :)