Coding Challenge 2: Writing Procedures

Assigned
Monday, 2 February 2026
Summary
In this coding challenge you will write your own procedures that rely heavily on booleans, predicates, and conditionals.
Collaboration
Normal collaboration policies for coding challenges apply to this assignment. See the syllabus for specifics.

Instructions

In this coding challenge you should create a file called LASTNAME-writing-procedures.scm which will contain all of your answers and code for this assignment. You should replace LASTNAME with your last name. Use comments to organize your file so it’s easily read by a human.

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! The following is a template you can use

;; CSC 151 (SEMESTER)
;; Coding challenge 2: Writing Procedures
;; Author: YOUR NAME HERE
;; Date: THE DATE HERE
;; Acknowledgements:
;;   ACKNOWLEDGEMENTS HERE (if none, write NONE)

If a problem asks for a written response as an answer, use a comment to include it in your code file. Make sure to name definitions exactly as prescribed in the problems.

Problem 1: Categorizing words

There are a number of ways to categorize words. They may be short or long. They may start with or contain certain letters. They may contain repeated letters. They may be near other words. They may be common. They may be uncommon.

(a) First, Pick and describe between six and ten categories. Then, write a procedure, (categorize-word word), that gives the category for a word as a string. You should use “uncategorized” for words that do not fit into your categories. For example,

> (categorize-word "aardvark")
"starts with vowel"
> (categorize-word "Grinnell")
"proper-name"
> (categorize-word "elephant")
"starts-with-vowel"
> (categorize-word "me")
"short"
> (categorize-word "hello")
"uncategorized"

If a word falls into multiple categories, you will pick only one. Be creative with your choice of categorization!

(b) (Optional problem, required for an E) In our consideration of conditionals, you’ve learned that and and or suffice to write many conditionals. Write a procedure, known-or-unknown which returns the string “some known category” if the given string is in one of your categories and returns “uncategorized” otherwise. For this solution you should use and and/or or. You may additionally use AT MOST one occurrence of if and no occurrences of cond.

Problem 2: Nearest Multiple

We have found that the procedures round, ceiling, and floor have come in particularly handy while we are cleaning our data to be whole numbers. However, these procedures are only capable of rounding numbers to nearest whole numbers. Sometimes it is helpful to round to the nearest multiple of 10, or the nearest multiple of 100.

Write a procedure (nearest-multiple val n) that rounds the parameter val to the nearest multiple of n.

Here are some example calls to the procedure.

> (nearest-multiple 32.7 10)
30.0
> (nearest-multiple 35.6 10)
40.0
> (nearest-multiple 10 3)
9
> (nearest-multiple -14 5)
-15

Hint: There is a straightforward mathematical solution to this problem, if you find yourself with lots of conditionals start from scratch or ask for a hint.

Submission guidelines

Submit your .scm file on Gradescope. Be sure that the file has the correct name (see the top of this assignment for naming instructions).

Grading rubric

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 might 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.

Redo or above

Submissions that lack any of these characteristics will get an N.

[] 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.

Meets expectations or above

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.
[] In problem 1, 6-10 categories are described and executed as described.
[] In problem 1, all categories are demonstrated through examples (including uncategorized)
[] In problem 2, `nearest-multiple` passes all of our tests.

Exemplary / Exceeds expectations

Submissions that lack any of these characteristics but have all of the prior characteristics will get an M.

[] In problem 1, categories are especially unique, or code is especially elegant.
[] In problem 1, `known-or-not` is written without `cond`, and with at most one `if`. 
[] In problem 1, `known-or-not` works correctly.
[] In problem 2, `nearest-multiple` is a straightforward (short) procedure.
[] In problem 2, more examples of the code working are given beyond what is provided in the assignment.