Fundamentals of Computer Science I: Media Computing (CS151.01 2008S)
Due: 9:00 a.m., Wednesday, 30 January 2008
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: Two to three 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 (e.g., “I consulted this person, who helped me do this”).
Send your answer to
The title of your email should have the form
CSC151.01 2008S Assignment 2: Drawing Smileys, Revisited and should contain your
answers to all parts of the assignment. I prefer that you put your
answers in the body of the message, rather than as an attachment.
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, we asked various groups to consider mechanisms for drawing smiley faces. Given the limits of class time, we were not able to consider every mechanism. Since then, we've also learned another mechanism for describing images: The GIMP tools.
What kinds of things might one consider in assessing the various solutions? One might reflect on the accuracy and complexity of each algorithm. One might look at the use of various algorithm components (repetition, conditionals, naming, subroutines, etc.) One might compare the different core operations.
Write instructions for drawing a smiley face.
In those instructions, you should assume that the person doing the drawing has been so corrupted by the impressionists that the primary thing they know how to do is draw a dot on the canvas in a specified color at a specified location.
The person following the instructions will be drawing the smiley face on a canvas 101 millimeters by 101 millimeters. The tip of the paintbrush is about one millimeter by one millimeter. To simplify your descriptions, the canvas is represented by a grid of size 100x100. In referring to a point on the grid, you need to indicate 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 the person reading your instructions can figure out sets of dots that meet clearly-specified 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 your reader 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
Write instructions for drawing a smiley face in a square that is 101 centimeters by 101 centimeters. Your reader will be drawing the face on the floor with pens whose tips are approximately one centimeter wide.
In those instructions, you should assume that your reader is limited to the following basic actions.
For example, to have your reader draw the outline of a blue square of edge length one foot, you might tell your reader 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 your reader will start at the center of the area in to draw, and that your reader is facing North.
Note that it is relatively straightforward to draw the outline of a circle or face using turtles: You repeatedly move forward a small amount and turn a small amount. It is a bit more complicated to draw a filled-in circle. Please try to figure out how.
Write instructions for drawing a smiley face.
In these instructions, you should assume that your reader is using GIMP to draw, that they want to draw a smiley face that is 101 pixels wide and 101 pixels high, and that they are familiar enough with GIMP to identify and use tools. You will, however, have to be very precise in describing where on the image window they should click.
You have now explored a variety of models of drawing: drawing through circles (done in the lab), drawing through grids of dots (as in part one), drawing through turtle motion (as in part two), and drawing through GIMP tools (as in part three).
a. Which was the easiest model in which to describe how 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?
d. If you had to draw a spiral, which would you prefer? Why?
The first criterion we will use in evaluating your assignments is correctness - is each set of instructions likely to produce the desired image. As we consider correctness, we will also check to see whether you have avoided ambiguous instructions and how easy it is for a reader to misinterpret those instruction.
The second criterion we will use is creativity. We will consider whether you have used innovative or particularly interesting techniques for giving instructions or analyzing the choices in part four.
Copyright (c) 2007-8 Janet Davis, Matthew Kluber, and Samuel A. Rebelsky. (Selected materials copyright by John David Stone and Henry Walker and used by permission.)
This material is based upon work partially supported by the National Science Foundation under Grant No. CCLI-0633090. Any opinions, findings, and conclusions or recommendations expressed in this material are those of the author(s) and do not necessarily reflect the views of the National Science Foundation.
This work is licensed under a Creative Commons
Attribution-NonCommercial 2.5 License. To view a copy of this
or send a letter to Creative Commons, 543 Howard Street, 5th Floor,
San Francisco, California, 94105, USA.