A Python-based automation tool I wrote as a freshman to solve the “Term Master Schedule” problem (and used throughout my undergrad from 2016 to 2020).

The Problem

Manually creating a university schedule involves solving a Constraint Satisfaction Problem (CSP) with multiple variables:

  • Hard Constraints: No time overlaps between classes.
  • Soft Constraints: Preferences for “no 8 AMs,” specific lunch breaks, or maximizing free days.

The naive approach (manually checking every possible combination) becomes intractable as the number of courses and sections grows.

The Solution

Rather than manually checking permutations, I built a script that:

  1. Scraped Data: Parsed the Drexel WebTMS (Term Master Schedule) using lxml to build a localized dataset of course availability.
  2. Solved for X: Implemented a recursive backtracking algorithm to generate every valid schedule permutation that satisfied user-defined constraints.

The Algorithm

The core of this project is a recursive_generator function that implements a valid CSP solver using backtracking. It performs a recursive depth-first search that:

  1. Takes a set of variables (courses).
  2. Checks constraints (time overlaps, lunch hours, max classes per day).
  3. Backtracks when a branch fails.

This is legitimate computer science, the same pattern used in everything from Sudoku solvers to compiler register allocation.

Retrospective (2025)

This tool saved me (and several friends) hours of planning time each quarter. While the scraping logic was fragile (dependent on 2017 HTML structures), the core logic (a depth-first search through the state space of possible schedules) remains a fundamental algorithmic pattern.