Problem. Place n queens on an n × n chessboard so that no two share a row, a column or a diagonal. Return all
distinct solutions, each as a list of strings (Q for a queen, . for empty).
n = 4 → . Q . . . . Q .
. . . Q Q . . .
Q . . . . . . Q
. . Q . . Q . .
This is the classic constraint satisfaction problem: every choice (a queen's column in a row) restricts all later choices, and the art is detecting a dead end as early and as cheaply as possible.
ML context. Constraint problems are everywhere in ML infrastructure: placing jobs on GPUs so that no two memory-hungry jobs share a device, assigning model shards to machines under bandwidth limits, scheduling evaluation runs that can't overlap on the same accelerator, generating test cases that satisfy a set of rules. The toolkit is the same: backtracking with O(1) conflict checks when you need every answer, and local search when you need one good answer for a large instance (Change B).