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

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

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?

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

»
3 года назад, # |
Rev. 3   Проголосовать: нравится +25 Проголосовать: не нравится

Practice

Spoiler

»
3 года назад, # |
Rev. 2   Проголосовать: нравится +31 Проголосовать: не нравится

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 года назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    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 года назад, # ^ |
        Проголосовать: нравится +16 Проголосовать: не нравится

      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 года назад, # ^ |
      Rev. 2   Проголосовать: нравится +6 Проголосовать: не нравится

      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 года назад, # ^ |
      Проголосовать: нравится +1 Проголосовать: не нравится

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

    • »
      »
      »
      3 года назад, # ^ |
        Проголосовать: нравится +4 Проголосовать: не нравится

      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 года назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

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