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

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
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
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education