Portmint Lighthouse
Coding Basics

What Is an Algorithm? (It’s Just a Recipe)

The word "algorithm" sounds like something only a scientist in a lab coat would say. It shows up in news headlines and serious-sounding articles, and it can feel like a locked door you were never given the key to.

Here is the good news. You already use algorithms every day. You just call them something simpler.

A Recipe Is an Algorithm

An algorithm is a set of step-by-step instructions for getting something done.

That's it. That's the whole idea.

Think about a recipe for grilled cheese. It might read like this:

  1. Butter two slices of bread.
  2. Put cheese between them.
  3. Heat a pan on medium.
  4. Cook the sandwich about three minutes per side.
  5. Take it off when both sides are golden.

Follow those steps in that order, and you get a grilled cheese sandwich. Skip a step, or do them out of order, and you get something else (or a small kitchen fire). The recipe is the algorithm. The sandwich is the result.

A computer works the same way. When we want a computer to do a job, we write out the steps clearly, one after another, and the computer follows them exactly. The computer is the cook. The algorithm is the recipe.

Why "Exactly" Matters So Much

Here is the part that trips people up. A computer is the most literal cook you will ever meet.

If your recipe says "add salt," a human cook knows to add a pinch. A computer does not guess. It will sit there confused, or it will dump the entire box of salt in, because no one told it how much. A good recipe leaves nothing to the imagination: "add one quarter teaspoon of salt."

That is why writing an algorithm takes care. You can't say "make the sandwich nice." You have to spell out every step in a way that leaves no room for a guess. The computer will do precisely what you wrote, not what you meant.

This is also why algorithms can be powerful. Once you have written the steps correctly, the computer can repeat them a thousand times, perfectly, without getting tired or bored or distracted. Your grilled cheese recipe makes one sandwich. A computer following a recipe can do its job a million times before lunch.

You Already Think in Algorithms

You don't need a computer to use this idea. Look around your own life and you'll spot recipes everywhere.

Tying your shoes is an algorithm: a fixed set of steps that always gives the same result. So are the directions to a friend's house ("turn left at the gas station, then it's the third house on the right"). So is the morning routine you follow without even thinking about it.

An algorithm is simply the plan. Computers happen to be very good at following plans, which is why the word comes up so often when we talk about them. But the thinking behind it, breaking a task into clear, ordered steps, is something humans have done forever.

The Takeaway

The next time you hear someone say "algorithm" and feel a little flicker of being left out, remember the grilled cheese. An algorithm is just a recipe: a list of clear steps, in the right order, that gets a job done.

You have written and followed thousands of recipes in your life. You understand this far better than you thought.

Keep going. Every big, intimidating tech word has a plain idea hiding underneath it, and once you've cracked one, the next gets easier. You're doing great. 🔦

Keep going with Pip

Like thinking in steps? Pip's Programming, from Zero course turns that into real code — one friendly lesson at a time.

Take Pip's Programming, from Zero course →