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 on 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 screen has three parts:

  • on the left is the lesson, with your instructions below it,
  • in the middle is the editor: its left column holds the blocks you can use, and next to it is the area with the Start block,
  • on the right is 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 phone, switch between the parts with the Lesson, Code and Output tabs at the top.

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 Run under the editor. 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

The dog is three tiles away from the goal. Drag three Move forward blocks under the Start block and click Run.

Start programming for free

By signing up, you agree to the Terms of Service and Privacy Policy.

Or sign up with:

1/7