We said that programming is not (just) writing code in a language like Python or C++. Programming is designing algorithms.
Often, when people hear the word Algorithm, they imagine complex mathematical formulas floating in the air or artificial intelligences controlling the world. But the concept is much simpler.
What is an algorithm
An algorithm is nothing more than a systematized strategy for solving a problem. Learning to program is, in reality, learning to break down big problems into small, precise, and ordered steps that a machine can follow.
The language is just the tool to communicate it to the machine.
Today we are going to learn what exactly an algorithm is, what rules it must follow, and how we can design them before touching a single key.
Definition of algorithm
If we get formal, an algorithm is an ordered and finite set of operations that allows finding the solution to a problem.
We can see it as a “black box” that transforms an input into an output through a series of predefined steps.

The classic analogy is a cooking recipe:
- Input: Ingredients (eggs, flour, sugar).
- Algorithm: The steps to follow (beat, mix, bake at 180º for 20 min).
- Output: A cake.
However, unlike a recipe that can say “add a pinch of salt” (something subjective), a computer algorithm must be a mathematically precise definition.
Three fundamental properties
For a list of instructions to be considered a real algorithm, it must meet three sacred characteristics. If it fails any, it is not an algorithm.
Each step must be perfectly defined. There can be no room for interpretation.
- ❌ Bad: “Move the character a little to the right.” How much is a little?
- ✔️ Good: “Move the character 10 pixels to the right.”
The computer is an obedient but dumb soldier; it will do exactly what you tell it, no more, no less.
Given the same set of input data, the algorithm must always produce the same result. If you add 2 + 2 today, it must give 4. If you add it tomorrow, it must still give 4.
What about random numbers? Actually, computers generate “pseudo-random” numbers. They are deterministic algorithms that appear random, but if you know the initial seed, you can predict the exact sequence.
An algorithm must have an end. It must be designed to finish after a finite number of steps.
If you create a sequence that never ends (an unintentional infinite loop), the program “hangs”. That is not a valid algorithm for solving a problem, it’s a mistake.
A practical example: The lamp doesn’t work
Let’s see how a programmer would think about an everyday problem to turn it into an algorithm.
Problem: I enter a room, flip the switch and the light doesn’t turn on.
Algorithm Design:
Start
Is the lamp plugged in?
- NO: Plug in the lamp → End
- YES: Continue.
Is the light bulb burnt out?
- YES: Change the light bulb → End
- NO: Continue.
Buy a new lamp.
End
It might seem silly to you, but you just defined an ordered, finite, and precise process (a series of IF-ELSE) to fix a breakdown.
Design tools
Before writing code, we use intermediate tools to structure our ideas. It’s like making the blueprint of a house before laying bricks.
They are graphical representations of the algorithm. They use standard geometric shapes connected by arrows to show the flow of logic.
- Ovals: Start and End.
- Rectangles: Actions (e.g.,
x = x + 1). - Diamonds: Decisions (e.g.,
Is x > 10?).
They are very useful for visualizing complex “paths” and decisions, although they can become chaotic in very large programs.
It is the intermediate step between human language and programming language. It doesn’t have a strict syntax (you don’t have to put ; at the end), but it mimics the structure of code.
Its goal is for any programmer to understand it, regardless of whether they will later program it in Java, Python, or C#.
For example, an algorithm to know if a number is even.
START
READ number
IF (number MODULO 2) IS EQUAL TO 0 THEN
PRINT "It's even"
ELSE
PRINT "It's odd"
END IF
END
Personally, I really hate pseudocode 😎.
Building blocks
No matter how complex a program is (from Tetris to a rocket’s navigation system), everything is built by combining only three basic control structures:
Sequence: One step goes after another.
Selection (Conditionals): Making decisions based on a question.
Iteration (Loops): Repeating an action while a condition is met.
This is known as the Structured Programming Theorem (or Böhm-Jacopini theorem). With these three Lego pieces, you can build any computable logic.
