File Exchange

image thumbnail


version (4.66 KB) by

Web Sudoku solver, using MATLAB algorithm as a .NET component created by MATLAB Builder for .NET, wi

6 Ratings



View License

SOLVE_SUDOKU.M -- This file contains the code for solving the Sudoku board, and should be deployed as a .NET assembly. It accepts as input a 9-by-9 array, where 0 represents a blank square, and the digits 1-9 represent any initial values in the grid. The function returns the solved board, if a solution exists, and a flag indicating whether the code was successful at finding a solution. To solve the puzzle, the code uses an algorithm that makes recursive calls to the solver function after choosing one of the possible candidates for a square. If a square does not have any possible candidates, the algorithm backs up to a previous square, and tries another possible candidate there before proceeding.
SUDOKU.ASPX -- The front-end web page is an ASP.NET file that creates a 9-by-9 grid of text boxes, allowing users to enter the values for a Sudoku puzzle. After a user clicks the submit button, this code posts the data in the grid to solver.aspx.

SOLVER.ASPX -- This ASP.NET code accepts the input data from sudoku.aspx, packages it in a .NET array, and calls a method of the Sudoku object to solve the puzzle. After receiving the output in the form of a two-dimensional array, the ASP.NET code formats the array to display the solution on the screen.

For more information on solving Sudoku puzzles, check out the following reference:
Delahaye, Jean-Paul. "The Science Behind Sudoku." Scientific American June 2006: 81-83.

Note: Certain boards take longer to solve than others. It may be helpful to set the timeout for the ASP.NET page appropriately for boards that take an excessive amount of time to complete.

Comments and Ratings (8)


really nice!

Jerry Gao

Hi, I am using Visual Studio, How do I place the SOLVE_SUDOKU.M file in the solution resource manager? many thanks.


it's ok

marutha nayakam

Daniela Macena

how I make to see the program correctly? I need to make some configuration in the Web.config or the Assemby ?


Roxana Vasiliu

basma hussien

Richard Lonscak


Updated license


Updated information in readme file.


Added BSD license.

MATLAB Release
MATLAB 7.2 (R2006a)

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video