cs-016 — The Meeting Scheduler
| Field | Value |
|---|---|
| id | cs-016 |
| difficulty | Advanced |
| topics | python, sequences, constraints |
| lecture | lecture-04 |
| estimated time | 5-minute attempt + 10-minute discussion |
| prerequisites | functions, dictionaries, and earlier algorithmic patterns |
| objective | design the algorithm, verify it on edges, and argue correctness or trade-offs |
| solution | held by the instructor; discussed after the attempt |
Problem
Given busy intervals and a meeting length, output all possible start times in a day. First encounter with walking through sorted intervals.
Your deliverable is the computed aggregates for the worked instance, the accumulator update rules, and one test input that breaks a careless initialisation. 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: busy [(9,10), (11,12.5)]; day 8..18; meeting 1.5 h
- Output: starts at 12.5, 13.0, 13.5, ..., 16.5 (9 starts; the 8-9 and 10-11 gaps are each too short for 1.5 h)
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
- Walk the sorted busy list keeping 'free from' marker; a start works if the whole meeting fits before the next busy block.
- Every aggregate here is a small machine: state + update rule.
- The initial value is part of the algorithm, not a detail.
Discussion starter
After the solution is revealed, the class spends five minutes on this prompt: "Where exactly would this solution break first if the input grew to a million items — and would anything break at all?"
Constraints and assumptions
- Difficulty: Advanced (functions, dictionaries, and algorithmic reasoning assumed).
- Topics: python, sequences, constraints.
- Classroom-scale inputs unless the problem says otherwise.
- Time-box: about five minutes for a defensible plan; a complete solution may take longer and that is expected - state where you would resume.
- 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: Implement your pseudocode and verify it against your hand trace.