CSCI 107 Assignment 8
- Due Date: Monday, April 24th no later than 11:59 p.m.
- Partner Information: You may complete this assignment individually or
with exactly one classmate.
- Submission Instructions (working alone): Upload your solution,
entitled YourFirstName-YourLastName-Assignment8.py
to the BrightSpace Assignment 8 Dropbox.
- Submission Instructions (working with one classmate): Upload your
solution, entitled
YourFirstName-YourLastName-PartnerFirstName-PartnerLastName-Assignment8.py
to the BrightSpace Assignment 8 Dropbox. Note: If you work with a
partner, only one person needs to submit a solution. If you both
submit a solution, the submission that will be graded is the one from
the partner whose last name comes alphabetically first.
- Deadline Reminder: Once the submission deadline passes, BrightSpace
will no longer accept your submission and you will no longer be able
to earn credit. Thus, if you are not able to fully complete the
assignment, submit whatever you have before the deadline so that
partial credit can be earned.
Recursive Diamonds
The purpose of this assignment is to help you gain experience using recursion
to solve problems. Examine the following five drawings
until you understand the pattern:
- Level 0: The base case. A single
diamond appears.
- Level 1: Two smaller diamonds are
embedded in the large diamond. The distance between the
top and bottom of each smaller diamond is 1/3 of the distance
between the top and bottom of the large diamond.
The upper smaller diamond shares its top point with the large diamond.
The lower smaller diamond shares its bottom point with the large
diamond. The two smaller diamonds are produced by recursive calls.
- Level 2: There are now three sizes of diamonds:
large, medium and small. Two small diamonds are embedded in each medium
diamond, just like each medium diamond is embedded in the large diamond.
- Level 3: There are now four different sizes
of diamonds. The pattern continues.
- Level 4: The pattern continues.
Starting Code
Download assignment-8.py and rename it
according to the instructions above. Examine the code carefully
until you fully understand it.
Note: the colormap global variable contains
a list of five colors. If level
is an integer between 0 and 4 inclusive, colormap[level]
accesses the color in that position. For example, if level had
the value 3, colormap[level] would be "green".
Requirements and Grading
- 20 points - The Level 0 drawing is correct (5 points, all or nothing)
and the color is correct (5 points, all or nothing).
- 20 points - The Level 1 drawing is correct (10 points, all or nothing)
and the colors are correct (10 points, all or nothing).
- 10 points - The Level 2 drawing is correct, even if the colors
are not (all or nothing).
- 10 points - The Level 3 drawing is correct, even if the colors
are not (all or nothing).
- 10 points - The Level 4 drawing is correct, even if the colors
are not (all or nothing).
- 10 point - No changes are made to the provided program except to add
the missing function and its relevant comments.
- 20 points - The solution uses recursion appropriately to solve
the problem.