cs-004 — The Library Fine Formula
| Field | Value |
|---|---|
| id | cs-004 |
| difficulty | Expert |
| topics | specification, edge cases |
| lecture | lecture-01 |
| estimated time | 5-minute attempt + 10-minute discussion |
| prerequisites | the full Block I-III toolbox and proof-shaped reasoning |
| objective | make and justify design decisions where the method itself is the challenge |
| solution | held by the instructor; discussed after the attempt |
Problem
A library charges fines with a tiered rule (per day, capped, and waived under conditions). Turn a vague policy into an exact formula, including what happens on the return day itself.
Your deliverable is the stated assumptions, the rule list, the decision for the worked instance, and one contested case. If the problem is ambiguous anywhere, state the assumption you are making and carry on — a stated assumption is part of a good answer.
Examples
- Input: 0.50/day for days 1-7, 1.00/day for days 8-30, cap 10.00; returned on day 5, on day 12, on day 40
- Output: 2.50; 7.00 (5 charged days: 7+5x1.00); 10.00 (capped); same-day return 0.00
Solve for the worked instance first. Then ask what would change if one number, name, or condition were replaced by something stranger.
What to notice
- The ambiguity to resolve first: is the return day itself charged? State the decision, then compute.
- Writing the rules IS the solution; code is transcription.
- Every assumption is a place where two good answers can differ.
Discussion starter
After the solution is revealed, the class spends five minutes on this prompt: "Which assumption would you attack first if you had to argue the other side?"
Constraints and assumptions
- Difficulty: Expert (independent design decisions and proof-shaped arguments assumed).
- Topics: specification, edge cases.
- Classroom-scale inputs unless the problem says otherwise.
- Time-box: about five minutes for the attack plan; the full argument may exceed the box - outline the proof strategy instead of grinding details.
- Optional stretch (not required): describe an alternative approach and say when it beats the obvious one.
Hints and extension
- First nudge: identify the pattern the worked instance uses before computing anything.
- If stuck after three minutes, write the input/output line you expect and trace the smallest example by hand.
- After the reveal, attempt the extension below before the next lecture.
- Extension challenge: Re-solve with a second, different assumption and compare the answers.