csp-1.4.0: Discrete constraint satisfaction problem (CSP) solver.

Synopsis

# Overview

This constructs a discrete constraint satisfaction problem (CSP) and then solves it. A discrete CSP consists of a number of variables each having a discrete domain along with a number of constraints between those variables. Solving a CSP searches for assignments to the variables which satisfy those constraints. At the moment the only constraint propagation technique available is arc consistency.

Here is a simple example which solves Sudoku puzzles, project Euler problem 96.

import Data.List
solveSudoku puzzle = oneCSPSolution $do dvs <- mapM (mapM (\a -> mkDV$ if a == 0 then [1 .. 9] else [a])) puzzle