What Is an Algorithm
Welcome to the Algorithmic Thinking course! Before you learn to write code in a programming language, you'll learn the most important skill a programmer has: breaking a task down into exact steps. You'll build programs out of blocks, like a construction kit, so you don't have to worry about typos and can focus on the thinking itself.
An algorithm is an exact procedure for solving a task: a series of steps that you just carry out one after another, and the task is done. You know algorithms from everyday life:
- a pancake recipe,
- instructions for building a LEGO set,
- directions: "Turn left at the corner and go straight ahead to the post office."
A computer, however, doesn't figure anything out by itself. It does exactly what you tell it, not a step more or less, and it can't tell what you meant. That's why the steps of an algorithm have to be exact and unambiguous. "Go to the goal" isn't an algorithm for a computer, but "move forward three times" is. An algorithm written down so that a computer can carry it out is called a program.
In this course, you'll program a dog. The exercise page has three parts:
- the lesson, which you're reading now, with your instructions at its end,
- the editor, where you build the program: it has a column with the blocks you can use, and an area with the
Startblock, - the dog's world. The dog walks on the light path and has to get to the green tile with a flag: the goal. You can turn the view by dragging it and zoom in with the mouse wheel or two fingers.
On a big screen, you see all three at once. On a phone, each of them has its own tab at the top: Lesson, Code and Output.
You build the program under the Start block. To add a block, drag it from the column of blocks under the Start block (or under the last block of the program) and let go when it snaps into place. The Move forward block moves the dog one tile in the direction it's facing. If you add a block you don't want, drag it back to the column of blocks and it disappears.
To run the program, click the Run button. The dog then carries out the blocks one after another, from top to bottom, and the block it's carrying out lights up in the editor. The button with a circular arrow near the Run button resets the program to how the exercise started.
Instructions
- 1
The dog is three tiles away from the goal. Drag three
Move forwardblocks under theStartblock and click Run.