The idea of an algorithm is core to computer science. So what is an algorithm? If you have ever used the instructions from some Lego set for building a Lego building, car or animal, then you have followed algorithms for fun yourself and you have been a computational agent.
An algorithm is just a special kind of set of instructions to be followed to achieve something. That something that is to be achieved could be anything (as long as someone is clever enough to come up with instructions to do it). It could be that the instructions tell you how to multiply two number, how to compute an answer to some calculation; how to best rank search results so the most useful are first; or how to make a machine learn from data so it can tell pictures of dogs from cats or recognise faces. The instructions could also be how to build a TIE fighter from a box of lego pieces, or how to build a duck out of 5 pieces of lego or, in fact, anything you might want to build from lego.
The first special thing about the instructions of an algorithm is that they guarantee the desired result is achieved (if they are followed exactly) … every time. If you follow the steps taught in school of how to multiply those numbers then you will get the answer right every time, whatever numbers you are asked to multiply. Similarly, if you follow the instructions that come with a lego box exactly and you will build exactly what is in the picture on the box. If you take it apart and build it again, it will come out the same the second time too.
For this to be possible and for instructions to be an algorithm, those instructions must be precise. There can be no doubt about what the next step is. In computer science, instructions are written in special languages like pseudocode or a programming language. Those languages are used because they are very precise (unlike English) with no doubt at all about what the instruction means to be done. Those nice people at Lego who write the booklets of instructions in each set, put a lot of effort into making sure their instructions are precise (and easy to follow). Algorithms do not have to be written in words. Lego use diagrams rather than words to be precise about each step. Their drawings are very clear so there is no room for doubt about what needs to be done next.
Computer scientists talk about “computational agents”. A computational agent is something that can follow an algorithm precisely. It does so without needing to understand or know what the instructions do. It just follows them blindly. Computers are the most obvious thing to act as a computational agent. It is what they are designed to do. In fact, it is all they can do. THey do not know what they are doing (they are just metal and silicon). They are machines that precisely follow instructions. But a human can act as a computational agent too, if they also follow instructions. If you build a lego set following the instructions exactly making no mistake then you are acting as a computational agent. If you miss a step or do steps in the wrong order of place a piece in the wrong place or (heaven forbid) do something creative and change the design as you go, then you are no longer being a computational agent. You are no longer following an algorithm. If you do act as a computational agent you will build whatever is on the box exactly, however big it is and even if you have no idea what you are building.
Acting as a computational agent can be a way to destress, a form of mindfulness where you switch off your mind. They can also be good to build up useful skills that matter as a programmer: like attention to detail, or if following a program helping you understand the semantics of programming languages so learn to program better. It is also a good debugging technique, and part of code audits where you step through a program to check it does do as intended (or find out where and why is doesn’t).
Algorithms are the core of everything computers do. They can do useful work or they can be just fun to follow. I know which kind I like playing with best.
– Paul Curzon, Queen Mary University of London
Lego Computer Science

Part of a series featuring featuring pixel puzzles,
compression algorithms, number representation,
gray code, binary and computation.
More on …
- Lego Computer Science
- Ludwig Wittgenstein: tautology and truth tables
- LGBTQ+ Computer Science Greats
Subscribe to be notified whenever we publish a new post to the CS4FN blog.
This page is funded by EPSRC on research agreement EP/W033615/1.

The Lego Computer Science series was originally funded by UKRI, through grant EP/K040251/2 held by Professor Ursula Martin, and formed part of a broader project on the development and impact of computing.

