← Back to the site

Aug – Sep 2026 · age 17 · tool / optimisation

School Timetable Solver

Fill in a spreadsheet, double-click one file, get a legal timetable for a whole Tunisian secondary school.

Test school
40 classes, 37 teachers, 580 lessons
Hard-rule violations
0, checked twice
Source
Public on GitHub

The problem

Timetables in Tunisian secondary schools are built by hand in aSc TimeTables, over weeks. They have to follow the ministry's rules (circular 51/2018) and still leave teachers without holes in their week. And when a teacher leaves in November, a lot of that work starts again.

What I built

A generator that reads one Excel workbook, finds a timetable that obeys every ministry rule, makes teachers and pupils as comfortable as it can, and exports XML that aSc TimeTables 2013 imports directly. No programming needed: fill the workbook, double-click run.bat, import the file.

It also writes a report of which preferences were met or missed, and why.

the AI writes the solver. the solver places the lessons.

How it works

What went wrong / what I learned

A solver faithfully satisfies the wrong rule. If I encoded a rule badly, the solver would obey the bad version perfectly. That's why the checker exists: two independent programs agreeing is the real guarantee.

Time buys comfort, never correctness. Measured on the fake school: at 2 minutes, 22 of 37 teachers had a clean week; at 10 minutes, 35 of 37. The hard rules were perfect in both runs.

Don't trust a file format, test it. I proved the XML export against the real aSc program (days, groups, A/B weeks, options) before building the solver around it.

Still to do: it hasn't run on a real school's data yet, and double-hour blocks and morning/afternoon cohorts aren't coded.

Built with an AI coding assistant as pair programmer; the design, the architecture and the testing are mine. The AI never places a lesson: running it costs zero AI tokens.

"INFEASIBLE" is my favourite error message.

Stack

Links

The repo includes a small fictional school so you can try it without real data.

← majdlahbib.com