Problem 58458. You are given a matrix A of size m x n representing a Sudoku puzzle. The matrix contains digits from 1 to 9, where 0 represents an empty cell. Your task is to solve the Sudoku puzzle by filling in the empty cells with the correct digits.
The provided code implements a solution for solving Sudoku puzzles using a recursive backtracking algorithm.
Sudoku is a logic-based number puzzle where the goal is to fill a 9x9 grid with digits from 1 to 9, following specific rules. The grid is divided into 9 sub-grids of size 3x3, and each cell must be filled with a digit such that the following conditions are satisfied:
1. Each row must contain all digits from 1 to 9 without repetition.
2. Each column must contain all digits from 1 to 9 without repetition.
3. Each 3x3 sub-grid must contain all digits from 1 to 9 without repetition.
Write a function solve_sudoku(A) that takes the matrix A as input and returns the solved Sudoku puzzle as the output. If a solution is not possible, the function should return an empty matrix.
Solution Stats
Problem Comments
-
3 Comments
William
on 25 Jun 2023
There are two 7's in the last column of y_correct, and no 7's in column 2. There may be other issues as well.
Christian Schröder
on 4 Jul 2023
Additionally, the definition of A in the (sole) test is broken. Is this solvable at all in its current state?
Christian Schröder
on 4 Jul 2023
Finally, the LP-based solver that Ned Gulley presented indicates that there is no valid solution matching the given numbers, at all. So it's not just that the solution in the test suite isn't a valid Sudoku solution --- it seems that no valid solution exists, period.
Solution Comments
Show commentsProblem Recent Solvers0
No solvers yet, be the first player to solve this problem.
Suggested Problems
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!