3-6 Lego Data Representation, Part 1

Objectives:
In this lesson, we'll encode an "instruction table" for building a LEGO tower using binary. We will need to break down the task into steps, describe those steps in a consistent and systematic way, and use our encoding skills to convert ideas into binary.
• Students will practice representing numbers in binary.
• Students will use binary digits to encode and decode messages.
• Understand the importance of binary numbers in computer science.

## Engage

This video showed the construction of the tallest LEGO Tower ever built. It involved teamwork and collaboration from families and schools all over Brazil, and probably a lot of organization!

How would you organize a big project like this?

Encoding Lego Instructions

Agent Zhivago is trapped and can only escape if he builds a LEGO key. However, the instructions for building the key are encrypted in some kind of code that he has to decode. In fact, Agent Zhivago has recognized the code as binary, which is a code you've been working with.

But before we look at coded instructions, let's think about instructions in general.
Suppose we built this LEGO tower:

How would you tell a friend how to build the exact same tower?
Write down a set of instructions on the activity handout.

## Understanding Block Encoding and Decoding

LEGO blocks have four attributes: color, size, position, and orientation. These attributes can help us when we make instructions.

How would you describe the four attributes of each block in this tower?

We want to be able to describe these attributes with binary, so let's encode the four attributes. First, let's look at color and size. We can create the following codes:

What kind of block is represented with color 010 and size 010010?

Next, we'll have to define a way to represent position. We want this to be as clear and simple as possible, so we define a coordinate system:

The position of each block can be defined by the x and y coordinates of its bottom left corner.

What are the coordinates of each of the blocks?

Then, we can just convert these coordinate numbers into binary:

These are the same binary number conversions you've been practicing!

Last, we can assign binary codes for orientation. Here, we're mostly worried about which way the block is rotated:

We can encode these orientations:

We've described each LEGO block's four attributes (color, size, position, and orientation) in normal language and in binary. Now, instead of giving the instructions in sentences, we can put it into a table where each line represents a step of the instructions. Notice that we've numbered the blocks, so that there's one step for each LEGO block.

Can you convert the information in this table to sentences to tell a friend how to build the tower?

Using our code, we can translate all of the information in this table into binary. Here's the legend for our code:

And here's the binary instruction table:

How would you use the binary instruction table to build a structure? Would you need to decode it first?

## Building the Encoding

Here's an encoded instruction table for a small LEGO tower. Can you build the tower?

Here's the legend for our encoding:

Don't have LEGOs on hand? No worries! You can build the structure virtually using Build with Chrome online.
If you need a hint, click here for the decoded instruction table.