who is playing?
image: ai-generated (gpt-image-2)
last week, you were the receiver.
look at the card.
decide which colour it is.
write down the matching symbol.
wait for the next one.
that was an algorithm.
you were the machine.
steps so precise you could follow them without understanding a thing.

four lines, one of them hard

look at the card.
decide which colour it is.
write down the matching symbol.
wait for the next one.
one of these four will take you three weeks to hand over.

one more algorithm, live

1stand in a row.
2look at your right neighbour.
3if they are shorter than you, swap.
4at the end of the row, start again.
5a full pass without a swap: done.
you just ran bubble sort.
computers sort like this, only faster.
it ended because a full pass had no swap left. remember that.
a program is an algorithm
written for a machine.
and it must be complete: the machine adds nothing.
a program is a list of instructions.
something follows that list.
exactly, and in order.

the list at work

one line at a time, top to bottom. every line changes what you see.

one line

same instruction, different values

led.set_color(255, 0, 0) led.set_color(0, 0, 255)
same instruction, different values, different result.

1 · one after another

led.set_color(255, 0, 0) wait(1) led.set_color(0, 0, 255)
two lines swapped is a different program.

with a pause, and without

the program is not broken. it is too fast for your eyes.

pause in the middle, or at the end

no line is missing. it is still a different program.

2 · a value with a name

bright = 255 led.set_color(bright, 0, 0) wait(1) led.set_color(bright, 0, 0)
one place to change instead of three.

3 · again

colours = [red, green, blue, yellow] for colour in colours: led.set_color(colour) wait(1)

the loop you write, and what actually happens

the loop you write
colours = [red, green, blue, yellow] for colour in colours: led.set_color(colour) wait(1)
what actually happens
the same two lines, four times, one value and one second per pass.

4 · only if

for colour in colours: led.set_color(colour) if colour == yellow: wait(3) else: wait(1)
now the run depends on something that changes along the way.

when does this end?

while True: led.set_color(red) wait(1) led.set_color(blue) wait(1)
never: the condition is always true, and the body has no way out.
"my program hangs" almost always means "my loop has no way out".

what does it cost?

correct is the minimum. after that, compare how the cost grows.

an error message

an error message is information,
not a verdict.
read it out loud. most of the time it says exactly what is wrong.
now watch me get it wrong.

two ways to ask

never keep code
you cannot change.
every hand-over ends with a small change: another colour, another waiting time.
if you cannot change it, you did not take it over. you copied it.

today

1one colour, on.
2four colours, in a loop.
3blinking, and you can change how fast.
number 3 is the real one: the speed must change in one place, without digging through the code.