cs-120 — The Exam Seating
| Field | Value |
|---|---|
| id | cs-120 |
| difficulty | Expert |
| topics | optimization, search |
| lecture | lecture-30 |
| 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
Seat students so no two friends sit adjacent in a grid, or report impossible. Constraint search with pruning; when to admit failure honestly.
Your deliverable is the enumerated answer, the space count, and the pruning rule with its measured effect. 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: 4x4 grid, friends pairs (r1,c1)-(r2,c2) must not sit adjacent (share an edge); 6 students, 2 friend pairs
- Output: a valid seating or 'impossible' - backtracking with adjacency pruning; report the search count
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
- Place students cell by cell; prune the moment a friendship is violated. Count nodes visited - pruning is measurable.
- Brute force is a legitimate algorithm when the space is honest about its size.
- Pruning is not cheating; it is arithmetic applied early.
Discussion starter
After the solution is revealed, the class spends five minutes on this prompt: "Double the input size: is this still acceptable? Show the arithmetic."
Constraints and assumptions
- Difficulty: Expert (independent design decisions and proof-shaped arguments assumed).
- Topics: optimization, search.
- 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: Reformulate with a different objective and describe how the optimum moves.