This device is not compatible.
You will learn to:
Formulate Sudoku as a CSP.
Formulate the 8-Queens problem as a CSP.
Solve CSPs using Python.
Reduce one problem to another problem.
Skills
Data Visualization
CSP Formulation
Constraint Libraries
Prerequisites
Intermediate knowledge of Python
Familiarity with constraint satisfaction problems
Basic understanding of Sudoku and the 8-Queens problems
Technology
Python
Project Description
Constraint satisfaction problems (CSPs) are problems in artificial intelligence and computer science whose solution must satisfy a particular set of constraints. A constraint is a condition or restriction that a solution must meet. CSPs are often used to model problems associated with scheduling, planning, and resource allocation. These problems can be solved using various techniques, including search algorithms, constraint programming, and local search.
A Sudoku board is a 9x9 grid divided into 3x3 sub-grids called regions. The objective is to fill the grid with the digits 1–9 such that each digit appears in each row, column, and region just once. Sudoku is usually presented as a partially completed grid, and the player must fill in the blanks according to the rule above.
The 8-Queens problem is another classic example of a constraint satisfaction problem. The goal is to place eight queens on a chessboard such that no two queens threaten each other. This means that no two queens can be placed on the same row, column, or diagonal.
In this project, we’ll formulate both problems as CSPs and solve them using constraint programming in Python.
Project Tasks
1
Getting Started
Task 0: Getting Started
Task 1: Import the Necessary Modules
2
Solve the Sudoku Problem
Task 2: Generate a Sudoku Problem
Task 3: Define the Variables
Task 4: Create the CSP Instance and Add Variables
Task 5: Add the Constraints
Task 6: Satisfy the Constraints and Print the Solution
3
Solve the 8-Queens Problem
Task 7: Create a Problem and Add Variables with Domains
Task 8: Add Constraints to the Problem
Task 9: Satisfy the Constraints and Get the Solution
Task 10: Create a Board and Show the Solution
Congratulations!
Relevant Courses
Use the following content to review prerequisites or explore specific concepts in detail.