Showing posts with label Repeating patterns. Show all posts
Showing posts with label Repeating patterns. Show all posts

Tuesday, July 29, 2014

Solutions: A Maze Using Repeat Loops in Pro-Bot

1.  Assuming that you start at the leftmost corner and facing forward, here is a possible solution for the maze given in the figure:


Rpt 3 [
Fd 12
Rt
]
Fd 2
Rt
Rpt 3 [
Fd 8
Lt
]
Fd 2
Lt
Rpt 3 [
Fd 4
Rt
]



2.  Assuming that you start at the leftmost corner and facing forward, here is a possible solution for the maze given in the figure. The program is same as the one above, with an addition of two more instructions at the end, to draw the solid line at the bottom of the maze.


Rpt 3 [
Fd 12
Rt
]
Fd 2
Rt
Rpt 3 [
Fd 8
Lt
]
Fd 2
Lt
Rpt 3 [
Fd 4
Rt
]
Bk 2
Fd 10


A Maze using Repeat Loops in Pro-Bot: Assignment 2

(1)   Here is a maze that combines parts of 3 squares. All measurements are in centimeters.

The outer section has 12 cm sides. The middle section has 8 cm sides and the inner-most section has 4 cm sides.

Each of the partial squares can be drawn using Repeat Loops in Pro-Bot, as we saw in our previous assignment. Can you write a program for Pro-Bot to draw this figure?

Your program will have three sets of Repeat Loops as well as other instructions in between. So far, all of the programs that you wrote for Pro-Bot used either a sequence of simple instructions or stand-alone Repeat Loops. This is a good example to see a mix of both in a program.






















(2)   This is a follow-up exercise to the above maze. All measurements are in centimeters.

The outer section has 12 cm sides. The middle section has 8 cm sides and the inner-most section has 4 cm sides. Each of the sections can be drawn using Repeat Loops in Pro-Bot, as we saw in our previous assignment.

Can you write a program for Pro-Bot to draw this figure?

Can you modify the previous program for the maze, adding just a couple lines of code, for Pro-Bot to draw this figure?

This is a good exercise in modifying or editing an existing piece of code to create a new functionality.






















Here is a set of solutions.

Monday, July 28, 2014

Solutions: Repeat Loops in Pro-Bot Assignment 1

Here is a set of solutions to the Repeat Loops Assignment 1.  The Start point is marked in each figure. Pro-Bot is assumed to be facing forward at the starting position.




1.  Repeat Loops Pattern 1

     Rpt 3 [
     Fd 6
     Rt
     Fd 6
     Lt
     ]



2.  Repeat Loops Pattern 2

 
     Rpt 2 [
     Fd 6
     Rt
     Fd 6
     Rt
     Fd 6
     Lt
     Fd 6
     Lt
     ]



3.  Repeat Loops Pattern 3

   
     Rpt 3 [
     Fd 6
     Rt
     Fd 6
     Rt
     Fd 12
     Lt
     Fd 6
     Lt
     Fd 6
     ]

Repeat Loops in Pro-Bot: Assignment 1

(1)  Using Pro-Bot, trace the pattern for a set of stairs that looks like the following. Each step is 6 cm tall and 6 cm wide. Do you see a pattern in this figure that keeps repeating? Circle the repeating pattern. Can you write a program for Pro-Bot to draw this pattern using Repeat Loops? Assume Pro-Bot is facing forward starting at the base of the steps.





(2)  Using Pro-Bot, trace the following pattern. Each side of the figure measures  6 cm each.  Do you see a pattern in this figure that keeps repeating? Circle the repeating pattern. Can you write a program for Pro-Bot using Repeat Loops to draw this pattern? Assume Pro-Bot is facing forward at the start point on the left end.







(3)  Using Pro-Bot, trace the following pattern. Each short side of the figure measures  6 cm each. The longer sides are 12 cm each. Do you see a pattern in this figure that keeps repeating? This is a bit more tricky than the previous two figures. Circle the repeating pattern that you identified. Can you write a program for Pro-Bot using Repeat Loops to draw this pattern?