reading-notes

View the Project on GitHub Abu-laban/reading-notes

Solving Problems

Common mistakes

The most common mistake I see when conducting interviews or watching someone try to solve a programming problem is they try to start writing code as soon as possible.

Another big mistake is trying to over solve the solution on the first iteration. Keep it simple, don’t try to get fancy.

A simple set of steps

  1. Read the problem completely twice.

         This is the single most important step.
           You may even want to read the problem 3 or 4 times.
    

If you don’t understand the problem, you cannot solve it. Do not worry about wasting time here, because the better you understand the problem, the easier it will be to solve it.

  1. Solve the problem manually with 3 sets of sample data.

“Nothing can be automated that cannot be done manually!”

Programming is automation plain and simple. You may have the ability to skip the manual steps and jump directly to code, but there is a manual process which is the foundation of any code you write.

  1. Optimize the manual steps.

People often don’t realize how valuable this step is. It is much easier to rearrange and reconstruct and idea or algorithm in your head than it is in code.

  1. Write the manual steps as comments or pseudo-code.

Many times you can skip this step if you have a really good handle on the problem or your previous steps

  1. Replace the comments or pseudo-code with real code.

This step should be extremely easy at this point. If you have done all the other steps, this step involves no problem solving at all.

All we do here is take each comment and convert it into a real line of code.

  1. Optimize the real code.

Sometimes this step isn’t necessary, but it’s worth taking a look at your code and figuring out if you can cut out a few lines or do something simpler.


Act like you make $1000/hr

What you think is what you become.

If you think your time is worth a few bucks an hour, that you’ll begin to act like it. You’ll find yourself saying “yes” to meaningless, pointless obligations.

But if, in your heart, you know your time is valuable…

Still, many people waste much of their time on pointless, low-quality activities that don’t help them reach their true goals — their mission.

The truth is, most people value their time at far, far less than it’s worth.

They spend hours watching low-quality television and social media when they should be productive and effective.

The difference between successful people and really successful people is that really successful people say no to almost everything.

    Value your time at what it deserves to be. The higher the value, the more important and productive work you’ll do — and the less trivial and mindless tasks you’ll get caught in.

How to think like a programmer

“Everyone in this country should learn to program a computer, because it teaches you to think.”

Why is this important?

Problem solving is the meta-skill.

We all have problems. Big and small. How we deal with them is sometimes, well…pretty random.

Unless you have a system, this is probably how you “solve” problems:

  1. Try a solution.
  2. If that doesn’t work, try another one.
  3. If that doesn’t work, repeat step 2 until you luck out.

So, what should you do when you encounter a new problem?

  1. Understand

  2. Plan

  3. Divide

  4. Stuck?

Practice

Don’t expect to be great after just one week. If you want to be a good problem-solver, solve a lot of problems!


The 5 Whys

You can use 5 Whys for troubleshooting, quality improvement, and problem solving, but it is most effective when used to resolve simple or moderately difficult problems.

The model follows a very simple seven-step process:

  1. Assemble a Team

  2. Define the Problem

  3. Ask the First “Why?”

  4. Ask “Why?” Four More Times

image1

image2

  1. Know When to Stop

  2. Address the Root Cause(s)

  3. Monitor Your Measures