cs-030 — The Age Gate
| Field | Value |
|---|---|
| id | cs-030 |
| difficulty | Foundational |
| topics | testing, requirements |
| lecture | lecture-08 |
| estimated time | 5-minute attempt + 10-minute discussion |
| prerequisites | lectures 1-2 (problem framing, precise pseudocode) |
| objective | recognise the pattern, translate it into precise steps, and trace it correctly |
| solution | held by the instructor; discussed after the attempt |
Problem
A system admits visitors 12 and older on weekends, 16 and older on weekdays. Derive test cases from the requirement, including the boundary birthdays.
Your deliverable is the complete test table with expected outputs, the boundary rationale, and the automated run result. 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: ages 11, 12 (Sat), 12 (Mon), 15 (Mon), 16 (Mon)
- Output: refused; admitted; refused; admitted; admitted (weekday boundary is 16)
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
- Boundary grid: day type x age around the thresholds; every cell is a test row.
- A test case is a falsifiable claim about the requirement.
- Boundaries are where specifications and implementations disagree.
Discussion starter
After the solution is revealed, the class spends five minutes on this prompt: "Which row in your table would you defend hardest, and why?"
Constraints and assumptions
- Difficulty: Foundational (early-semester techniques assumed: precise statements, traces, simple loops).
- Topics: testing, requirements.
- Classroom-scale inputs unless the problem says otherwise.
- Time-box: about five minutes; naming the pattern and stating the assumption is already a pass, completing the calculation is the stretch.
- 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: Add two boundary rows to your test table and justify each.