## Sudoku

Version 1.0.0.0 (43.5 KB) by
Sudoku for MATLAB.
Updated 20 Dec 2005

Editor's Note: This file was a File Exchange Pick of the Week

Sudoku is a game that is very fashinable in Britain at the moment. Everyone seems to be captured.

The rules are very simple:
Fill in the grid so that every row, every column, and every 3x3 box contains the digits 1 through 9.

That's all there is to it. There's no math involved. The grid has numbers, but nothing has to add up to anything else. You solve the puzzle with reasoning and logic. It's fun. It's challenging. It's addictive!

I tried one of these puzzles last Sunday and spent the rest of the afternoon with the Times on my lap scribbling little numbers only to find out after hours that my first guess was wrong and I had to restart. How frustrating!

So I decided to solve this problem once for all. Why must I think when that can be done by my computer?

You can use the program for solving sudokus yourself (and get some help if you need it) or let the computer solve them for you (much more satisfactory :)

You can also generate your own puzzles. But please be aware that the generating option is not too sophisticated. It works by basically finding a solution to a random sudoku and then taking away random numbers.
A simple rule is applied to see if the puzzle is unique: the solution of the puzzle is compared to the solution of the transposed puzzle. If both are the same then the puzzle is very probable unique. For difficult puzzles this sometimes takes some time.

-------INSTALLATION---------
unzip sudoku.zip (the zip contains also the gui-files, so its some files. The actual sudoku file is only one .m-file)

change into the created directory
type "sudoku"
A figure appears in the top right corner that gives you options:
"Emtpy puzzle" creates an empty field that you can fill with whatever you like
"file name" declares the name of the file that you can save or load (the latest one from the Times is in "sudoku_saved").
"load puzzle" loads the puzzle with the filename.
"save puzzle" saves the current puzzle under the filename.
"check possible" plots small pencilmarkers for all possible entries (that are all entries that are not conflicting with the existing entries).
"check neccessary" checks all fields if its neccessary to be filled with a number (checks each line, column and subsquare for fields in which only one number can go).
"solve" uses the two methods and finds a solution recursivly.

Start with loading the suggested puzzle (its a very tough one!) You can try to solve it yourselve by clicking into a square and insert a number between 1 and 9. If you type in 0 the square is cleared. If its not a valid number (contradicts the rules as stated above) the number is printed in red.

Pressing the "check possible" button shows you what numbers are possible at every given time.

Try to solve an empty puzzle or create some that have funny properties (e.g all magic squares...)

If you are looking for more puzzles try eg
www.timesonline.co.uk/section/0,,18209,00.html or
www.griffiths-jones.co.uk/sudoku/

FAQ:
Q: When I start your program get the message
??? Undefined function or variable 'uipanel'.
A: Sorry, you need MATLAB version 7 for this program

Q:??? Error using ==> class
Class parameter is not a valid class name...
A: this error results from a wrong zip-file. Its solved now.

If for what ever reason the gui appears partly out of the screen, type in "movegui", to recenter it

### Cite As

Stefan Bleeck (2024). Sudoku (https://www.mathworks.com/matlabcentral/fileexchange/7676-sudoku), MATLAB Central File Exchange. Retrieved .

##### MATLAB Release Compatibility
Created with R14
Compatible with any release
##### Platform Compatibility
Windows macOS Linux
##### Categories
Find more on Sudoku in Help Center and MATLAB Answers
##### Acknowledgements

Inspired by: Create Interactive GUIs

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

#### sudoku/@parameter/

Version Published Release Notes
1.0.0.0

updated FAQ, correcteted zip archive