Sudoku Solver – Version 1.1

I made the code cleaner and decomposed the one long loop from before into functions. Also, a new technique, naked pair, has been added.

The code can be viewed online here:

http://codetidy.com/2854/  : The JavaScript

http://codetidy.com/2855/ : The HTML

Download from here (Mediafire) or here (Rapidshare).

Please like and share ~_~ Also, add a comment if you have anything to ask.

Sudoku Solver

The other day I was getting bored like hell. So I began solving a couple of sudoku puzzles. Then I thought of writing a little script that can actually solve a sudoku .

First, I had to choose a language. At first I wanted to go with python but in the end I decided to go with JavaScript instead. This I did particularly because of the ease with which input and output can be manipulated using jQuery. Also, I can form a much better user interface using HTML.

For those of you who don’t want to know how I made it, you can download it below. Note that this script would solve a majority of sudoku but certainly not all. This is because I have only ‘taught’ the script two techniques that are used in soduku solving. First one is naked single and the other is hidden single. These techniques can solve most of the sudoku of easy and medium levels. But sometimes it may not work.

Download it here.(Mediafire). Or here (Rapidshare).

Clicking on populate will fill the grid with a sample sudoku puzzle. Clicking on solve will solve the puzzle. Note that if on clicking solve nothing happens then that means that the puzzle cannot be solved by the script. Also, if the puzzle does not have a unique solution then 2 or 3 cells may remain empty at the end.

Notes about the code:

  1. The code is quite messed up, for now. I didn’t have any plan in my when I wrote it and so it’s all messed up. I will shortly divide the code into functions and clean the code up.
  2. Also, as I said before, only 2 techniques have been employed in this script. So, it is quite possible that it may not be able to solve the sudoku you give it to.
  3. Soon, I will add more techniques and when it is finally ready, I will post it here along with the added techniques.