Bibbidi_Babbidi_Boo's blog

By Bibbidi_Babbidi_Boo, history, 4 days 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?

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

»
4 days ago, # |
  Vote: I like it 0 Vote: I do not like it

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

»
4 days ago, # |
Rev. 3   Vote: I like it +25 Vote: I do not like it

Practice

Spoiler

»
4 days ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

Use pen & paper to solve problems and practice daily. Slowly but surely you can see your improvement.

»
4 days ago, # |
  Vote: I like it 0 Vote: I do not like it

We use something called a "magic keyboard" that translates ideas to code. you can use the coupon code "PRACTISE_INFINTY" to buy it.

»
4 days 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.

  • »
    »
    4 days 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.

    • »
      »
      »
      4 days 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.

    • »
      »
      »
      4 days 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.

  • »
    »
    4 days 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?

    • »
      »
      »
      4 days 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.

»
4 days 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.

»
4 days ago, # |
  Vote: I like it 0 Vote: I do not like it

Another question but same answer : "How to get ideas ?"

»
4 days ago, # |
  Vote: I like it 0 Vote: I do not like it

If you know little bit of python just download Thonny, after downloading type your code in python and try to debug your code, you will understand What's happening with your code and you will able to make implementation.