Due: 4:00 p.m., Tuesday, 4 September 2007
Free extension of one day!
This homework is also available in PDF.
Summary: In this assignment, you will extend your work from the introductory lab on writing algorithms.
Purposes: To give you more experience thinking about writing algorithms. To give you the opportunity to identify parts of an algorithm.
Expected Time: One to two hours.
Collaboration: I would prefer that you work in groups of
size three. However, you may work alone, in a group of size two, or a
group of size four. You may discuss this assignment and possible
solutions with anyone you wish. If you discuss this assignment with
people other than group members, make sure to include a citation
I consulted this person, who helped me do
Submitting: Email me your answer.
Warning: So that this assignment is a learning experience for everyone, I may spend class time publicly critiquing your work.
In the first laboratory for this course, I asked various groups to consider mechanisms for drawing smiley faces. Given the limits of class time, we were not able to consider every mechanism. We were able to see two aproaches to drawing with circles, and a combined approach by two groups of drawing with pixels.
What kinds of things might we consider in assessing the various tasks? We might reflect on the accuracy and complexity of each algorithm. We might look at the use of various algorithm components (repetition, conditionals, naming, subroutines, etc.) We might compare the different core operations.
Write instructions for drawing a smiley face.
In those instructions, you should assume that I have been so corrupted by the impressionists that the primary thing I know how to do is draw a dot on the canvas in a specified color at a specified location.
I will be drawing the smiley face on a canvas 101 millimeters by 101 millimeters. The tip of my paintbrush is about one millimeter by one millimeter. To simplify your descriptions, I have broken down the canvas into a grid of size 100x100. In referring to a point on the grid, you need to tell me the row and column. We will start numbering with row 0 (the top row) and column 0 (the leftmost column). In referring to rows and columns, you may only use whole numbers.
Because it can be difficult to describe each dot individually, you may
also assume that I can figure out sets of dots that meet particular
criteria, so that you can give instructions like
put orange dots at
all positions in which the sum of the row number and the column number
is 10 or
put green dots in all positions in which the product of
the row number and column number is less than 20.
You may also assume that I can can compute functions, so that you can
write things like
for all integers, c, between 1 and
20, put a violet dot in the grid point whose column is c and
whose row number is c*c+5.
Write instructions for drawing a smiley face in a square that is 101 millimeters by 101 millimeters.
In those instructions, you should assume that I am limited in my actions to:
For example, to have me draw the outline of a blue square of edge length one foot, you might tell me to
This technique for drawing mimics one of the more popular ways to teach robots how to draw, and is called turtle graphics.
You may assume that I start at the center of the area in which I plan to draw, and that I am facing North.
You have now seen three sets of rules for describing drawings - The circle-based drawings we did in class, the grid-of-dots drawings you did in part one, and the turtle drawings you just did in part two.
a. Which was the easiest set of rules in which to draw a smiley face? Why?
b. If you had to draw a simple picture of a house, which would you prefer? Why?
c. If you had to draw a stick figure, which would you prefer? Why?
The first criterion I will use in evaluating your assignments is correctness - is each set of instructions likely to produce the desired image. As I consider correctness, I will also check to see whether you have avoided ambiguous instructions and how easy it is for me to misinterpret those instruction.
The second criterion I will use is creativity. I wil consider whether you have used innovative or particularly interesting techniques for giving instructions or analyzing the choices in part three.
Please submit this work via email. The email should be titled CSC151.02 Assignment 2 and should contain your answers to all parts of this assignment.
Please send your work as the body of an email message. I don't like attachments, and prefer not to receive them when they can be avoided.
Late August, 2007 [Samuel A. Rebelsky]
Saturday, 1 September 2007 [Samuel A. Rebelsky]
Monday, 3 September 2007 [Samuel A. Rebelsky]
I usually create these pages
on the fly, which means that I rarely
proofread them and they may contain bad grammar and incorrect details.
It also means that I tend to update them regularly (see the history for
more details). Feel free to contact me with any suggestions for changes.
This document was generated by
Siteweaver on Mon Dec 3 09:55:50 2007.
The source to the document was last modified on Mon Sep 10 20:50:00 2007.
This document may be found at
You may wish to validate this document's HTML ; ;Samuel A. Rebelsky, firstname.lastname@example.org
http://creativecommons.org/licenses/by-nc/2.5/or send a letter to Creative Commons, 543 Howard Street, 5th Floor, San Francisco, California, 94105, USA.