How to build logics in programming ๐Ÿง

How to build logics in programming ๐Ÿง

How to Build Strong Programming Logic in 21 Days

ยท

3 min read

Kartik Sharma, a software engineer at Anthropic, provides a compelling 21-day strategy for improving problem solving skills and developing strong programming logic. Through focused practice and revision over a short period, anyone can emerge with significantly enhanced abilities.

In this article, we will break down Kartik's approach in detail. We will first understand the typical struggles faced by programmers, then unpack each element of the methodology. An example problem is solved step-by-step to demonstrate the thought process clearly. Additional tips offer further guidance to stay motivated throughout the journey.

Common Coding Challenges

It is easy to feel alone when faced with coding difficulties, but Kartik emphasizes this is universal. Even experienced engineers like himself struggled early on, experiencing blanking out and feeling overwhelmed by others' abilities.

These challenges stem from an unclear thinking pattern when problems are presented. The brain must be trained to recognize problems at a deeper type level (arrays vs strings etc.) and procedure level (brute force vs optimized solutions). Without focused practice, the links aren't formed in the mind.

The 21 Day Mindset Shift

Kartik proposes committing fully to a structured routine for just 21 days. This relatively short period is enough time for habits to take root if done consistently each day.

The key steps are:

DayActivity
1-7Focus on one data type (e.g. arrays) and complete all easy problems
8-14Expand difficulty while taking tutorial notes
15-21Revise previous work and practice optimization

Step 1) Solve By Topic

Dedicate time each day solely to easy problems involving a single concept like arrays. This trains the brain to categorize each new problem.

Step 2) Connect To Real Life

Mapping abstract coding puzzles to real scenarios makes the logic more natural and intuitive to understand. For example, comparing coin values to element properties.

Step 3) Iterative Learning Cycle

Spend time each week watching tutorials, writing practice code, and consolidating notes. Bouncing between these three aids long-term retention versus one-off implementations.

Step 4) Build On Small Wins

Start simply to gain momentum via minor successes, as increasing difficulty will come with failure. Progress step-by-step to feel a sense of achievement boosting motivation.

Step 5) Schedule Revision Routinely

Carving out time weekly prevents knowledge from slipping away untouched. Regular review strengthens foundations to take problems to a deeper level over the months.

Step 6) Reward Your Efforts

Each phase completed deserves recognition to feel accomplished progress is being made. Non- coding rewards outside the routine avoid burnout.

Worked Example: Unique Element in Array

To demonstrate his process, Kartik walks through a classic "find unique element" problem:

Input: [1,2,1,2,5]
Output: 5

Brute Force Solution

  1. Match coins (elements) by value to locate the odd one out

  2. Translate to nested for loops in code

Optimized Solution 1: Sorting

  1. Arrange coins in ascending order

  2. Unique element stands out when values differ

  3. Implement with arrays sort() method

Optimized Solution 2: XOR Operation

  1. XOR returns 0 if values match, 1 if different

  2. XOR all elements to isolate unique value

  3. Single line of elegant code solves the problem

This detailed example unpacks the thought progression clearly. Seeing refinements builds both coding skills and conceptual understanding.

Additional Advice

  • Write code manually versus copy-pasting for deeper learning and retention.

  • Carve out time daily regardless of schedule - successful people make opportunities.

  • Motivations include respect, financial freedom and fulfilling potential to help others.

With diligent practice guided by this robust methodology, anyone can emerge a stronger problem solver within just three short weeks according to Kartik Sharma. Consistency is key to cementing new thinking patterns and reaping long-term benefits.

๐Ÿ’ก If you find this article helpful then don't forgot follow me in Github and Twitter .

Like ๐Ÿ’–

Share๐Ÿ”—

Follow me in Hashnode โœ…

Did you find this article valuable?

Support Today'sCode by becoming a sponsor. Any amount is appreciated!

ย