Intermediate Algorithms
Contents
Introduction
An algorithm is a list of steps you follow to finish a task. We use algorithms in our daily lives – from getting ready in the morning to solving math problems in school.
Have you ever given someone a task? For us humans, it’s easy to string together words to give each other commands – and for others to follow those commands. For example: Draw a checkerboard pattern using graph paper and a crayon. Following just one sentence, you are able to create a relatively complex pattern – a checkerboard.
Yet, it’s different for computers, which have very simple machine brains. While we have 10,000 words in the English language to choose from, computers work with a limited number of words. In the computing world, these are called ‘symbols’.
What is it?
Coding , or Programming , is simply the way people tell a computer what to do using instructions that the computer understands.
Computer science is the study of computers and the processes that use algorithms – including their principles, their hardware and software designs, and their impact on society.
What is the difference between an algorithm and a program?
An algorithm is the thinking behind what needs to happen, while the program is the actual instructions that make it happen. An algorithm has to be translated into a program before a computer can run it.
Activities
Algorithms in Everyday Life
Brainstorm with your team examples of algorithms that you do every day, like following a recipe to make Chicken Parmesan or understanding how to play your favorite board game. They may come from time you spend at home, at school or in your extracurricular activities. Then, select one example as a team and write down the steps that someone new to that activity would need to follow.
Graph Paper Algorithms
What if a computing machine had only five symbols? How would this influence how we write an algorithm for the machine to follow?
Divide your team into two smaller groups. Work together in your group to create a simple design in a 4x4 grid and then write an algorithm using only the symbol-based language on the right and a pencil.
To avoid any mix-ups, start your picture in the upper left-hand corner. Then, trade and try to create the other group’s design. Were you able to follow each other’s algorithm?
Challenge: As a team, create one new symbol together that tells the machine to change color. Add this new symbol to programming key. With only one symbol, how might you tell the machine which color to use in your design?
In your small groups, create a new design with three colors. Then, trade algorithms again and follow them to create the new design. How did you do this time?
Program a Robot in Lightbot
In this online game, players program the Lightbot robot to follow these symbols:
Open the Lightbot game and try the Stage 1: Basics puzzle – and only this puzzle. For an added challenge, try translating your Lightbot programs into words (like the ones next to the symbols above) on some scratch paper.
Build a Snowkid in Pencil Code
This is a great way to get familiar with Pencil Code, a visual programming environment that allows you to easily transition to text-based coding. Your first activity is building a snowkid, which is really just a younger version of a snowman.
1. Go to http://gym.pencilcode.net in your web browser.
2. Click on the blue button under ‘Draw’.
3. Complete the First Dot exercise and follow the instructions at the
top of the page.
4. Once finished, click on the ‘More Ideas’ button in the upper right
and follow the instructions.
5. When you’re ready, click on the ‘Draw a Snowkid’ exercise and
follow the instructions at the top of the page.
6. Click on ‘More Ideas’ to find out how to decorate your snowkid.