CEMC Banner

Problem of the Week
Problem B and Solution
Shelby’s Code

Problem

Shelby is using block coding to draw different shapes.

  1. Her first program is shown. What shape will be drawn after running this program?

    A alternative format for the first program
follows.

  2. Using the given blocks, write a program to draw the same shape as Shelby’s program, using fewer blocks. Notice that some blocks contain an empty box to be filled with a number.

    Blocks for part b.

    Move forward empty box steps.

    Move right empty box degrees.

    Repeat empty box times. This block   is shaped so that it can wrap around other blocks.

    Start of program for part b.

    Two blocks in a column. The top block has text on start. The bottom box has text pen down.

  3. Using the given blocks, write a program to draw the following shape:

    The outline of a plus sign shape. The interior of the shape is formed by a row of three squares and a column of three squares meeting at the centre.

    You may use a block more than once.

    Blocks for part c.

    Move forward empty box steps.

    Turn right empty box degrees.

    Turn left empty box degrees.

    Repeat empty box times. This block   is shaped so that it can wrap around other blocks.

    Start of program for part c.

    Two blocks in a column. The top block has text on start. The bottom box has text pen down.

Solution

  1. This program will draw a square. The table below shows the drawing progress and position of the pen as we trace through the program.

       
    Program Section Drawing Progress
    Two blocks in a column: on start, pen down. An arrow head pointing up.
    Two blocks in a column: move forward 10 steps, turn right 90 degrees. A vertical line with an arrow head at the top pointing to the right.
    Two blocks in a column: move forward 10 steps, turn right 90 degrees. A vertical line and a horizontal line form the left and top sides of a square. The right end of the top side has an arrow head pointing down.
    Two blocks in a column: move forward 10 steps, turn right 90 degrees. A vertical line, a horizontal line, and another vertical line form the left, top, and right sides of a square. The bottom end of the right side has an arrow head pointing to the left.
    Two blocks in a column: move forward 10 steps, turn right 90 degrees. A square. The bottom left corner of the square has an arrow head pointing up.
  2. By using the repeat block, we can use fewer blocks in the program, as shown.

    A program. Alternative format follows.

  3. There are several possible programs, depending on where the pen starts, and how many repeat blocks are used. Two programs are shown.

    An alternative format of the program
follows.

    An alternative format of the program follows.