Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Do Project 1 Sudoku Solution Validator (parts I and II) from Chapter 4 of the textbook. 1. Use different thread for each of the following:

Do Project 1 Sudoku Solution Validator (parts I and II) from Chapter 4 of the textbook.

1. Use different thread for each of the following:

Column0, Column1, Column2, Column3, Column4, Column5, Column6, Column7, Column8

Row0, Row1, Row2, Row3, Row4, Row5, Row6, Row7, Row8

Box0202, Box3502, Box6802, Box0235, Box3535, Box6835 Box6802, Box6835, Box6868

2. Your output should be like the following:

I certify that I have done this project by myself and am accountable in accordance with the John Jay Colleges rules about Academic Integrity if found otherwise.

This is a program written in using multithreading to verify the correctness of a Sudoku puzzle.

The program can verify a 9 X 9 Sudoku by checking the sum of each column, each row, and each of the nine (9) 3 X 3 blocks starting from the top left. It will verify if all of these have all digits from 1 to 9.

The input is read from a file called project1.txt attached with the submitted documents.

Here is the output:

Column0 satisfies the condition. (Or Column0 does not satisfy the condition.)

Column1 satisfies the condition. (Or Column1 does not satisfy the condition.)

Column2 satisfies the condition. (Or Column2 does not satisfy the condition.)

Column3 satisfies the condition. (Or Column3 does not satisfy the condition.)

Column4 satisfies the condition. (Or Column4 does not satisfy the condition.)

Column5 satisfies the condition. (Or Column5 does not satisfy the condition.)

Column6 satisfies the condition. (Or Column6 does not satisfy the condition.)

Column7 satisfies the condition. (Or Column7 does not satisfy the condition.)

Column8 satisfies the condition. (Or Column8 does not satisfy the condition.)

Row0 satisfies the condition. (Or Row0 does not satisfy the condition.)

Row1 satisfies the condition. (Or Row1 does not satisfy the condition.)

Row2 satisfies the condition. (Or Row2 does not satisfy the condition.)

Row3 satisfies the condition. (Or Row3 does not satisfy the condition.)

Row4 satisfies the condition. (Or Row4 does not satisfy the condition.)

Row5 satisfies the condition. (Or Row5 does not satisfy the condition.)

Row6 satisfies the condition. (Or Row6 does not satisfy the condition.)

Row7 satisfies the condition. (Or Row7 does not satisfy the condition.)

Row8 satisfies the condition. (Or Row8 does not satisfy the condition.)

Box0202 satisfies the condition. (Or Box0202 does not satisfy the condition.)

Box3502 satisfies the condition. (Or Box3502 does not satisfy the condition.)

Box6802 satisfies the condition. (Or Box680 does not satisfy the condition.)

Box0235 satisfies the condition. (Or Box0235 does not satisfy the condition.)

Box3535 satisfies the condition. (Or Box3535 does not satisfy the condition.)

Box6835 satisfies the condition. (Or Box6835 does not satisfy the condition.)

Box0268 satisfies the condition. (Or Box0268 does not satisfy the condition.)

Box3568 satisfies the condition. (Or Box3568 does not satisfy the condition.)

Box6868 satisfies the condition. (Or Box6868 does not satisfy the condition.)

3. Test your program by using a correct (you can use the one shown in the book) and one with one error by replacing the number in Row k and Column k with zero.

4. Submit a zip file containing Project1.c, project1.txt, and project1output.txt.

A Sudoku puzzle uses a 9 9 grid in which each column and row, as well as each of the nine 3 3 subgrids, must contain all of the digits 1 9. Figure 4.26 presents an example of a valid Sudoku puzzle. This project consists of designing a multithreaded application that determines whether the solution to a Sudoku puzzle is valid. There are several different ways of multithreading this application. One suggested strategy is to create threads that check the following criteria: A thread to check that each column contains the digits 1 through 9 A thread to check that each row contains the digits 1 through 9

Nine threads to check that each of the 3 3 subgrids contains the digits 1 through 9 This would result in a total of eleven separate threads for validating a Sudoku puzzle. However, you are welcome to create even more threads for this project. For example, rather than creating one thread that checks all nine columns, you could create nine separate threads and have each of them check one column. I. Passing Parameters to Each Thread The parent thread will create the worker threads, passing each worker the location that it must check in the Sudoku grid. This step will require passing several parameters to each thread. The easiest approach is to create a data structure using a struct. For example, a structure to pass the row and column where a thread must begin validating would appear as follows: /* structure for passing data to threads */ typedef struct { int row; int column; } parameters; Both Pthreads and Windows programs will create worker threads using a strategy similar to that shown below: parameters *data = (parameters *) malloc(sizeof(parameters)); data->row = 1; data->column = 1; /* Now create the thread passing it data as a parameter */ The data pointer will be passed to either the pthread create() (Pthreads) function or the CreateThread() (Windows) function, which in turn will pass it as a parameter to the function that is to run as a separate thread. II. Returning Results to the Parent Thread Each worker thread is assigned the task of determining the validity of a particular region of the Sudoku puzzle. Once a worker has performed this check, it must pass its results back to the parent. One good way to handle this is to create an array of integer values that is visible to each thread. The i th index in this array corresponds to the i th worker thread. If a worker sets its corresponding value to 1, it is indicating that its region of the Sudoku puzzle is valid. A value of 0 indicates otherwise. When all worker threads have completed, the parent thread checks each entry in the result array to determine if the Sudoku puzzle is valid.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

For fixed price constructioncontract that reqires more than one

Answered: 1 week ago