CS5: Introduction to Computer Science at Harvey Mudd College
CS5 Web > Homework2Gold
Submissions: CS submission site

CS 5 Homework 2, Spring 2024

Putting recursion to work!

Due: Tuesday, February 6 at 22:22:22 (22 seconds after 10:22 pm).

Problems:



Docstrings and Comments

Be sure each function you write has a docstring. The docstring should explain how many arguments the function takes, what these arguments are supposed to be, and what the function returns. The doctring is intended for the user of your function.

In contrast, comments in your code are used to explain details that are important to a programmer who might be reading your code (that "programmer" could be you—it's easy to forget what you had in mind when you wrote your code!). In cs5, we are less worried about comments for programmers than about the docstrings, which are for users.

We'll look for your docstrings, so do be sure to include them.


A Note on Using Recursion

Thursday's (not Wednesday's) assignment exercises the ability to write functions recursively. If you have some programming experience, you may be familiar with other, non-recursive strategies for solving these problems.

Even if you do know such non-recursive strategies, however, we ask that you use recursion to solve the problems on this assignment.

Our primary goal here is to practice an important problem-solving concept and technique -- one that can handle problems other techniques struggle with.