The situation
A piano teacher gives about 24 lessons across Mondays and Wednesdays at a school with two campuses. Every week the puzzle changes: a student can't come out of PE or sport, a year group has an assembly or an excursion or a swimming carnival, juniors have to finish earlier than seniors, seniors run on a two-week timetable, and some students can only come at recess or lunch. The two campuses are a fifteen-minute walk apart.
What I did
I built a scheduler that reads the school's calendars, works out who is free when, and hands the lot to a constraint solver (Google's OR-Tools). There are hard rules it can never break, and preferences it trades off against each other: don't make her come in for a single student, don't walk between campuses more than you have to, don't pull the same junior out of the same class two weeks running.
If a week genuinely can't fit everyone, it doesn't just fail. It places everyone it can and says by name who couldn't be fitted, so a person can decide.
The result goes straight into her Google Calendar. It also fills in the fortnightly timesheet she has to submit, and keeps an evidence pack of what was taught when, for audits.
How it turned out
The hardest part was never the maths. It was the school's data: year groups recorded wrong, one event per period for every class, a duty roster that was a picture inside a document, and a login behind two-factor authentication. The solver had its own bug too: an early version charged nothing for some walks between campuses and actually preferred more walking. I found it, counted real walks instead, and wrote the rules down: 30 of them.


