r/learnprogramming • • Oct 17 '26

I wanna ask how to develop logic in coding

In last contest I try to solve every problem but able to solve only one, after the contest I call my friend and asked him how he soved 4 of them, then he explained me so I solve those problems again and got correct. But I really wanna ask why I can't think like he did while giving contest. The logic he explained was so straight forward but why I can't get that at the time of contest. BTW it was codechef contest and its been 6-7 months I started giving contest but still struggling. What can I do to solve this problem. Pls help me with this

8 Upvotes

7 comments sorted by

View all comments

17

u/aqua_regis Oct 17 '26

Practice, practice, practice, and more practice. That's it.

Start away from the computer, with pencil and paper. Analyse your task. Break it down into smaller subtasks. Solve each of these your way. Write the steps down. Use flow charts, bulleted lists, pseudo code, whatever, but not real code.

Some older, closely related posts:

And finally, some book suggestions:

  • "Think Like A Programmer" by V. Anton Spraul
  • "The Pragmatic Programmer" by Andrew Hunt and David Thomas
  • "Structure and Interpretation of Computer Programs" (SICP) by Ableton, Sussman, Sussman
  • "Code: The Hidden Language of Computer Hardware and Software" by Charles Petzold

Last, a great practice site: https://exercism.org