CSci 1301: Problem Set 6
Due: Friday, November 15 at 11:59pm by e-mail
You are required to write signatures and descriptions for all
functions, and also descriptions of all your structures. Additionally,
functions, except the world problems, must be tested using
check-expect. Write your tests before you write a function (but feel
free to add more after it's been writen).
The quality of your tests will
be graded.
Make sure to have enough test cases to
demonstrate that the function is correct.
I may take
points off for a lack of testing (in addition to those taken off for incorrect behavior)
if your function doesn't work on
particular expected data and there is no test for it. It's much better
to leave a test that fails (perhaps in comments) that shows that the function
doesn't work on given data and you don't know how to fix it.
Problem 1: Written exercises
Written exercises can be submitted electronically or on paper, in one
of the
following ways:
- on paper in class on the due date or in my office (slide it under
the door if I am not there) at any point before the deadline,
- in an email message with the rest of your problem set,
- as an attachement to an email message with the rest of your
problem set,
- as a google doc shared with me. Please give me permissions to
re-share so that I can share it with the TA, and do not make any
changes after the submission deadline.
All exercises for this part are given
in the
section Intermezzo:
BSL
- Exercises 106 (question 3 only), 107 (questions 1,2 only), 108
(question 3 only), 109 (question 3 only), 110 (all quiestions,
justify your answers) (8 points)
- Exercise 112 (questions 2,3 only) (4 points)
- Exercise 115, 117 (note: evaluation of some expressions may lead
to an error) (8 points)
Problem 2: Finish the balloon problem (10 points)
Your task is to finish the balloon
exercise that we did in class. Specifically:
- Finish the problem by adding a random balloon at the bottom of
the canvas, at a random x coordinate, of a random size (i.e. the
scaling factor) between 0.5 and 1.5, and of a color randomly chosen
among several colors of your choice (with equal
probability). A new balloon apears on every clock tick. Implement
your solution and test it.
- Change your solution by adding an additional feature (you may
change your solution to the previous question; comment out the old
code, but don't delete it. You can add features such as: adding a
new balloon less than on every clock tick (you can make it
deterministic, such as adding one on every 2nd clock tick, or
probabilistic, such as adding a balloon with a probability 1/2). You
can add "wind" that makes balloons shift horizontally, in addition
to vertically. You can have a balloon pop at random, or when it hits
a tree branch.
Especially interesting solutions may get an extra credit.
Clearly document the features that you are adding. Make sure that your
functions have good names and signatures and descriptions.
Problem 3: Extended exercise (15 points)
Exercises 178, 179, 180
in section
13.1
Problem 4: Create your own problem (6 points)
Come up with your own problem that is solvable using recursion and
then solve it. Start with a description of what you are trying to do
(it's ok if it is informal at first), write it down in comments.
Make sure to write check-expect (and check-error, if
needed) tests, then the function signature and description, and then the
implementation. If any of your initial ideas changed during this
process, write down what changed and why.
The problem may or may not deal with lists. It's ok to use recursion
in helper functions.
Implementations
of Towers of
Hanoi will not be considered (it's a classical
recursion problem, and many implementations are avaiable in just about
any language).
The most interesting problems may get extra credit. Clearly indicate
which features of your solution you consider interesting (for
instance, it may be a very useful function, or it may be different
from uses of recursion that we've covered in class).
CSci 1301
course web site.