In this coding challenge we are providing you with starter code, CC3-template.scm. You should download this file and upload the given code to a new .scm file named exploring-course-data.scm.
At the top of your file, make sure to include your name, and any acknowledgements according to our collaboration policy. In that vein, now is a great time to review those collaboration policies!
Below that header, you’ll notice that there is a very large list of courses. You should be able to toggle to hide the list while you’re coding, as needed. Each course is represented by a string such as "80631 CSC-151-02 4.00 00 24 Functional Prob Solving w/lab". This string is arranged as follows.
This approach to representing data is typically called “fixed-width fields”. a
Our first step is to figure out how to extract all of the portions of a course. Write the following procedures.
(course-code course), which extracts the five-digit code
as a string.(course-department course), which extracts the three-letter
department code as a string.(course-number course), which extracts the three-digit
course number as a string.(course-section course), which extracts the two-digit
course section as a string.(course-credits course), which extracts the course credits
as a real number.(course-available course), which extracts the number
of available seats as an integer.(course-capacity course), which extracts the capacity
of the as an integer.(course-name course), which extracts the name of the
course.> (course-code "80495 THD-245-01 4.00 04 12 Lighting for the Stage")
"80495"
> (course-department "80495 THD-245-01 4.00 04 12 Lighting for the Stage")
"THD"
> (course-number "80495 THD-245-01 4.00 04 12 Lighting for the Stage")
"245"
> (course-section "80495 THD-245-01 4.00 04 12 Lighting for the Stage")
"01"
> (course-credits "80495 THD-245-01 4.00 04 12 Lighting for the Stage")
4.0
> (course-available "80495 THD-245-01 4.00 04 12 Lighting for the Stage")
4
> (course-capacity "80495 THD-245-01 4.00 04 12 Lighting for the Stage")
12
> (course-name "80495 THD-245-01 4.00 04 12 Lighting for the Stage")
"Lighting for the Stage"
In addition to extracting information, we may also want to compute values based on the information in a course. Write the following procedures:
(course-enrollment course), which gives the number of
students enrolled in a course.(course-level course), which gives the “level” of a course
as a string (“100”, “200”, “300”, or “400”).(course-sch course), which gives the “student credit hours”
for a course, the product of the number of students and the number of
credits.For example,
> (course-enrollment "80495 THD-245-01 4.00 04 12 Lighting for the Stage")
8
> (course-level "80495 THD-245-01 4.00 04 12 Lighting for the Stage")
"200"
> (course-sch "80495 THD-245-01 4.00 04 12 Lighting for the Stage")
32.0
> (course-enrollment "81348 ALS-100-04 2.00 -1 08 Brazilian Portuguese I")
9
> (course-level "81348 ALS-100-04 2.00 -1 08 Brazilian Portuguese I")
"100"
> (course-sch "81348 ALS-100-04 2.00 -1 08 Brazilian Portuguese I")
18.0
We’ve been working with individual courses. But we have a list of courses. And there are, of course, many things we can do with a list.
You can find the first few courses with a command like (list-take courses 20).
As you may have noticed, the courses are organized by course number. What
if we wanted to organize them in a different way?
Write a procedure, (sort-courses-by-course courses),
that rearranges the courses so that they are sorted by the course info.
Your procedure must return a list of courses ordered by department.
For courses in the same department, they must be ordered by course number.
When two courses have the same department and course number they should be
ordered by section number.
Hint: Recall that you can sort a list of strings with (sort courses
string<=?). How can you sort using part of the string? Here’s one approach:
Put the course info at the start of each string (using map), sort the
new list of changed strings (using sort), and then strip out the portion
that you added (using map again).
Hint2: There are other methods of completing this problem that don’t rely on map
if you want to think in a different way.
Write a procedure, (average-course-size courses), that
takes a list of courses as input and finds out the average course capacity size.
Using average-course-size and other procedures you have written or write,
find out the average course size in
a) any department of your choice
b) any course level of your choice
(When you submit this exercise, include the expressions you typed to compute those average sizes.)
Submit exploring-course-data.scm to Gradescope.
In grading your submission, we will look for the following at each level. Note that if a criteria does not pass a lower level, we will likely not check for criteria at the higher levels. We may also identify other characteristics that move your work between levels.
You should read through the rubric and verify that your submission meets the rubric.
Submissions that lack any of these characteristics will get an I.
[] Includes the specified file (correctly named).
[] Includes an appropriate header on the file that indicates the course, author, acknowledgements, etc.
[] Acknowledges appropriately.
[] Code runs in scamper.
Submissions that lack any of these characteristics but have all of the prior characteristics will get an R.
[] Code is well-formatted with appropriate names and indentation.
[] Code submission is organized with comments to indicate the start of new problems.
[] All Gradescope tests pass for Problem 1.
[] All Gradescope tests pass for Problem 2.
[] All Gradescope tests pass for Problem 3.
[] All Gradescope tests pass for Problem 4.
[] In problem 3, at least one helper function is used.
[] In problem 4, computation is shown for a specific department.
[] In problem 4, computation is shown for a specific course level.
Submissions that lack any of these characteristics but have all of the prior characteristics will get an M.
[] All code is exceptionally organized and easy to read, through the use of comments (to explain the purpose of different pieces of the code) and decomposition
[] In problems 3 and 4, helper procedure names follow Scheme naming conventions and make the purpose of the procedure clear.