cs-017 — The Pager Schedule
| Field | Value |
|---|---|
| id | cs-017 |
| difficulty | Beginner |
| topics | modulo, cycles |
| lecture | lecture-05 |
| estimated time | 5-minute attempt + 10-minute discussion |
| prerequisites | none |
| objective | state inputs, outputs, and assumptions, then solve a small instance by hand |
| solution | held by the instructor; discussed after the attempt |
Problem
On-call duty rotates among 5 people every day. Given the day number of the year and who starts, decide who is on call. Then: what changes if rotation skips weekends?
Your deliverable is the stated assumptions, the quotient/remainder arithmetic for the worked instance, the cycle rule in one sentence, and one boundary value (n = 0, or the wrap point) traced. 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: 5 people, rotation starts with person 1 on day 1; day 47
- Output: day 47 -> ((47-1) mod 5)+1 = person 2; with weekend skip: count only weekdays
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
- Modulo answers 'which slot in the cycle'; subtract 1 before, add 1 after, to keep person 1 on day 1.
- 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: "Propose one extra rule that would change the verdict — is it an improvement?"
Constraints and assumptions
- Difficulty: Beginner (no prior experience assumed).
- Topics: modulo, cycles.
- Classroom-scale inputs unless the problem says otherwise.
- Time-box: about five minutes for a first attempt; partial answers with clear reasoning are worth more than silent struggling.
- 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: Find the closed-form answer and prove it agrees with your loop.