Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Sudoku Is a game played on a square grid of 9 large blocks, each containing Its

ID: 3639418 • Letter: S

Question

Sudoku Is a game played on a square grid of 9 large blocks, each containing Its own 3x3 grid of cells. Here is an example: The rules are simple: each cell contains a number from 1 -9 the number In a given cell (i.f) cannot match the number in any other cell in row f or column J each block can only contain one entry' of each number from 1-9 Some cells are initially filled in and the goal is to find the unique assignment of numbers to the remaining cells that satisfies the above rules. This game can be seen a straightforward system of constraints. Design the CSP you will use to solve the Sudoku problem. Describe the variables, their domains and the constraints needed. We encourage you to use only binary constraints; it will make the implementation easier. You do not need to list all of them for this sub-question! Just specify all the constraints involving one variable: let's say the one in the center of the board.

Explanation / Answer

Variables : int A[9][9],i,j,lx,ly,x,y,n; A[9][9] is sudoku matrix. Top left block is (0,0) and bottom right is (8,8). Blank spaces will be filled with 0. i & j are used in loop. x and y are positions of current block being filled. n is the value to be placed at (x,y) [starting with 1 it varies upto 9] (lx,ly) are coordinates of the upper left block of smaller (3X3) square in which (x,y) lies. At any position (x,y), lx = x - (x%3) ly = y - (y%3) For n to be placed at (x,y), following conditions should be satisfied : 1) A[i][y] & A[x][i] should not be equal to n [for all i from 0 to 8] . 2) In the smaller square, n should not be there. This can be implemented ny using two for loops : for(i=lx ; i
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote