'Free' is not the same as 'available'
The challenge
A teacher with no class that period may still be unavailable. They may be on duty, at their daily limit, or already covering something else. A naive gap search returns names the office cannot actually use.
The approach
Availability is computed from the full set of constraints rather than the timetable alone, and candidates are ranked so the fairest option, usually whoever has covered least, appears first.
