Learn CSP Fundamentals through Interactive Map Coloring
Click on a region to select it, then choose a color from the palette below.
X = {A, B, C, D, E, F, G, H, I, J, K} - All regions on the map
For all Xi: D(Xi) = {Red, Blue, Green, Yellow, Purple, Orange}
Adjacent regions must have different colors: Xi โ Xj for all adjacent pairs
Real-time constraint checking shows which adjacency rules are satisfied (โ) or violated (โ)
Academic scheduling with instructor conflicts, room capacity, and prerequisite constraints
Assign courses to time slots while respecting all scheduling constraints.
X = {CS101-A, CS101-B, MATH101, CS201, PHYS101, MATH201} - Course sections to schedule
D(Xi) = {Mon-9, Tue-9, ..., Thu-13} - Available room-time slots (13 total)
โข Instructor Conflict: Dr. Smith cannot teach both CS sections simultaneously
โข Room Capacity: Large lectures need big rooms (A101=100, others=50 seats)
โข Instructor Availability: Dr. Brown unavailable Friday afternoons
Real-time constraint checking shows scheduling conflicts and satisfied requirements
Classic CSP demonstrating backtracking and constraint propagation on a chessboard
Place N queens on an NรN chessboard so no two queens attack each other.
X = {Qโ, Qโ, ..., Qโ} - Position of each queen (row i, column xแตข)
D(Qแตข) = {1, 2, ..., N} - Each queen can be in any column of its row
For all i โ j:
โข Column: xแตข โ xโฑผ
โข Diagonal: |xแตข - xโฑผ| โ |i - j|
Backtracking Search:
Time: O(N!), Space: O(N)
Real-time constraint checking shows which queens are attacking each other
Solve arithmetic puzzles where letters represent digits with unique assignments
Assign unique digits (0-9) to letters to make the arithmetic equation valid.
X = {S, E, N, D, M, O, R, Y} - Each unique letter in the puzzle
D(Xi) = {0, 1, 2, ..., 9} - Each letter can be assigned any digit
โข All Different: Each letter gets unique digit
โข No Leading Zero: First letters โ 0
โข Arithmetic Valid: SEND + MORE = MONEY
Constraint Propagation + Backtracking:
Time: O(10^n), Space: O(n) where n = unique letters
Real-time constraint checking for digit assignments and arithmetic validity
Classic 9ร9 grid puzzle demonstrating multiple constraint types: rows, columns, and boxes
Fill the 9ร9 grid so each row, column, and 3ร3 box contains digits 1-9.
X = {Cโโ, Cโโ, ..., Cโโ} - Each empty cell in the 9ร9 grid
D(Cแตขโฑผ) = {1, 2, 3, 4, 5, 6, 7, 8, 9} - Each cell can contain any digit
โข Row: All different in each row
โข Column: All different in each column
โข Box: All different in each 3ร3 box
Constraint Propagation + Backtracking:
Time: O(9^n), Space: O(1) where n = empty cells