kirankumarmitra's blog

By kirankumarmitra, history, 6 years ago, In English

How can I reduce sillies while in programming contests ?

For example, in the last contest I took in some other coding site, I solved (solved means got the idea, just need to implement them) FIVE questions within twenty mintues (out of two hour contest). Now the first two was completely trivial to implement — I did that within ten minutes. So half hour, two questions down and I only need to implement four — sounds trivial right ? But I couldn't successfully implement any of them ! In one question I forgot to use long long instead of int, in another I forgot to increment by one in a case (but I didn't test that case), and in another question I couldn't figure out how to implement them (it looked very difficult).

So some questions:

  • How do I reduce the excessive amount of sillies I make while implementing ?
  • How do I implement effortlessly ? (In ideal world, implementation shouldn't take much thought right ?)
  • How do stop losing my sweat over those edge cases/off by one errors ?
  • Vote: I like it
  • +22
  • Vote: I do not like it

»
6 years ago, # |
  Vote: I like it +28 Vote: I do not like it

Solve more problems. Since you are having implementation problems, also implement everything.

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

Auto comment: topic has been updated by kirankumarmitra (previous revision, new revision, compare).

»
6 years ago, # |
  Vote: I like it -20 Vote: I do not like it

How do I implement effortlessly ?

LoOOoOLoOOLoOLooOOoL. LMAO. You can never achieve that for all problems. For example, just take a look at the GCJ finalists, they also keep editing their implementations very slowly. You seldom have the "think carefully and code once" situation unless the problem is really easy.

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

    they also keep editing their implementations very slowly

    I'm not quite sure I understand, can you explain more? What is being edited?

»
6 years ago, # |
  Vote: I like it +20 Vote: I do not like it

How do I reduce the excessive amount of sillies I make while implementing ?

By practicing more.

How do I implement effortlessly ? (In ideal world, implementation shouldn't take much thought right ?)

No way. If implementation was a no-brainer, we won't ever need to design a program properly.

First, acknowledge that implementation is hard, and may well be harder than inventing the solution. Look at why it is hard for you. What consumes your time, attention, and effort? What happens when you give too little of these?

Knowing all that, try to manage the complexity of the solution, so that no single step is too complex for you. Perhaps you will want to chop it into a sequence of blocks each of which you know well how to implement, and clear connections between these blocks. Make sure to check that each block works correctly as you implement them. Make as little dependencies between the blocks as possible.

Also, you may want to try a longer contest format, or a larger project: anything which makes you write at least a couple thousand lines, and then add yet another unexpected feature on top of it. This will help realize the importance of planning your implementation and managing complexity, which will miraculously help in shorter programs too.

How do stop losing my sweat over those edge cases/off by one errors ?

By having less edge cases in the first place. Instead of implementing the first solution which comes to mind, think about it some more, and try to incorporate edge cases into the general case before proceeding to implementation.

Same with off-by-one errors. Try to design your code in such a way that it either works in every case if everything is right, or does not work in the majority of cases if you made a mistake somewhere. Try to reduce the number of possible code paths, even if it means that you sacrifice a bit of performance in some cases. Once you have the thing working, you can base a faster version on what already works, and only if it's really needed: the majority of places in your program are not computational bottlenecks. The "no solution" -> "correct but slow solution" -> "right solution" path is generally safer to follow than the "no solution" -> "fast but incorrect solution" -> "right solution" one.