Bibbidi_Babbidi_Boo's blog

By Bibbidi_Babbidi_Boo, history, 3 years ago, In English

Hey guys,

As you can see, I'm a grey coder and I'm not so great atm. But for most problems I'm able to think of a strategy or an algorithm that might work, but spend a lot of time translating the algo to code. How do you guys do it fast? Like do you write down all cases and go one by one or start writing the cpde immediately after reading a problem?

| Write comment?
»
3 years ago, # |
Rev. 3   Vote: I like it +25 Vote: I do not like it

Practice

Spoiler

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

Just practice. I don't start coding right after reading unless I have the complete solution down to details. Usually, I spend 30 seconds to 5-10 minutes just thinking about details I might have missed and easier/cleaner ways of implementing the solution even after having a correct general idea about the solution.

As an exercise: Try to think about the complete solution before coding. If you had to fix your idea in a big way then you probably could've saved time by thinking before coding.

Extra: use meaningful variable names. Anyway, coding an idea isn't that much of a problem when compared to having a fuzzy idea and thinking details aren't important.

  • »
    »
    3 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Do you always try to prove your correctness of solution or is it sometimes first AC then proof ? I have noticed that these certain kind of problems which require some proof of correctness always take away my time on proving them correct before I code.

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

      Usually it just takes intuition, like thinking out how you'd prove it, but not getting into all the details. It helps to think about the corner cases as well.

    • »
      »
      »
      3 years ago, # ^ |
      Rev. 2   Vote: I like it +6 Vote: I do not like it

      I usually stop when I feel I have all the details needed to make a formal proof but usually don't make that formal proof. Proof by AC is last resort to me, I prefer skipping the problem, reading the next problems and coming back to the skipped problem later into the contest (sometimes after reading the next problems, other times after solving the next problems). That also helps in keeping your mind fresh, same as going for a drink mid contest.

      Another way to put it: if needed, I'd be able to formally prove the large majority of problems I've solved but during contest there's no need for deep formalism.

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

    Thanks what you say makes sense. So by last detail do you mean like corner cases, data structure used and everything?

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

      Yes, think about those things before starting to code. If you stop for 5+ minutes during coding then you could've used that time thinking about things before coding.

»
3 years ago, # |
  Vote: I like it 0 Vote: I do not like it

My tip is to practice a lot like a really dude :( When everybody is tired, be the last one who continues to solve problems.