Write a function with the declaration safe = checkSudoku (board, row, col, num) board is a 4x4 matrix which contains the Sudoku board to check. Unfilled board cells are indicated by a NaN value. row and col are indexes to the check if the number num (between 1 and 4) can be inserted without causing a violation. i.e. does num already exist in the given row, column or 2x2 sub-block. Note that we do not need to check the entire board's validity (although you could try to do so as practice) since we will be filling our board one element at a time. The function returns a logical true or false value in the output safe depending on the outcome of the check. There are several ways to accomplish this functionality. Possible functions you may want to use are sort, unique, ismember, any, all. Note that NaN values are unequal to one another! Test your function with various inputs to see it is operating as expected! For example: >> checkSudoku (unsolvedBoard, 3, 1, 2) ans = 0

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter7: Arrays
Section7.6: The Standard Template Library (stl)
Problem 8E
icon
Related questions
Question

solve with MatLab

Write a function with the declaration safe = checkSudoku (board, row,
col, num)
board is a 4x4 matrix which contains the Sudoku board to check. Unfilled board cells
are indicated by a NaN value.
row and col are indexes to the check if the number num (between 1 and 4) can be
inserted without causing a violation. i.e. does num already exist in the given
row, column or 2x2 sub-block. Note that we do not need to check the entire board's
validity (although you could try to do so as practice) since we will be filling our
board one element at a time.
The function returns a logical true or false value in the output safe depending on
the outcome of the check.
There are several ways to accomplish this functionality. Possible functions you may
want to use are sort, unique, ismember, any, all. Note that NaN values are unequal to
one another!
Test your function with various inputs to see it is operating as expected!
For example:
>> checkSudoku (unsolvedBoard, 3, 1, 2)
ans = 0
Transcribed Image Text:Write a function with the declaration safe = checkSudoku (board, row, col, num) board is a 4x4 matrix which contains the Sudoku board to check. Unfilled board cells are indicated by a NaN value. row and col are indexes to the check if the number num (between 1 and 4) can be inserted without causing a violation. i.e. does num already exist in the given row, column or 2x2 sub-block. Note that we do not need to check the entire board's validity (although you could try to do so as practice) since we will be filling our board one element at a time. The function returns a logical true or false value in the output safe depending on the outcome of the check. There are several ways to accomplish this functionality. Possible functions you may want to use are sort, unique, ismember, any, all. Note that NaN values are unequal to one another! Test your function with various inputs to see it is operating as expected! For example: >> checkSudoku (unsolvedBoard, 3, 1, 2) ans = 0
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr