NotGivingUp's blog

By NotGivingUp, history, 5 years ago, In English

How do you people implement bugless code in one single go? In previous contest Div 2 — #564, I got WA on Div 2 C, Test case #5. After the contest, I realized that the mistake was something like:-

I often make silly mistakes while implementing something during the contest. I am able to solve Div 2 C after spending little time thinking on the problem but often end up making silly mistakes and after the contest, I regret a lot. Can you share some tips so that I can improve on avoiding silly mistakes in my code and write bugless code?

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

»
5 years ago, # |
  Vote: I like it +13 Vote: I do not like it

Just solve more tasks, there's no shortcut to it.

»
5 years ago, # |
  Vote: I like it +14 Vote: I do not like it

Do a plank for 60 seconds, take 30 seconds of rest, then do it again, problem solved.

Or just pay attention about what you write while you're writing, don't make code that you can't debug.

»
5 years ago, # |
Rev. 2   Vote: I like it +20 Vote: I do not like it

Can you share some tips so that I can improve on avoiding silly mistakes in my code and write bugless code?

An important point is experience (duh). For example, employing safe techniques such as using large array sizes to avoid off-by-one bugs. But an even more important point is the skill of testing. There is certainly no way to be sure that your code is bug free even if you apply rigorous testing (but rigorous testing gives confidence that the program will not break so easily).

On a side note, this is CP and not software engineering. So you will only have time to test critical cases.