Soduku solver

Soduku (Sudoku) is a Japanese number puzzle game that seems to be taking the world by storm. It’s played on a 9×9 grid. Each square can contain one of the numbers from 1 to 9 (inclusive). A given “problem” has some of the squares filled in, and you are required to fill in the remaining squares, satisfying the constraints:

  • Each row has to contain each of the numbers 1 through 9 exactly once.
  • Likewise for each column.
  • The board can be broken down into 9 3×3 squares (top-left, top-middle, top-right, etc.). Each of these has to contain each of the numbers 1 through 9 exactly once.

Anyway, these puzzles can get pretty tricky. Especially if you don’t know the third rule above — which until recently, I didn’t. Anyway, they’ve sufficient annoyed me now that I had to do something about it; so I wrote

The Langabi.name Soduku Solver

It’s not fancy, but is (in my opinion) very efficient. Enjoy!

Edit: Now available: an explanation of the method my solver uses, and the source code.

69 thoughts on “Soduku solver

  1. Hmm… I tried with a super hard soduku and the results just came out and here i am cracking my brains to solve it.

    😉

    Like

  2. 200308007
    100000005
    400759006
    809000504
    020000083
    304080709
    902845001
    500000002
    000102058

    Like

  3. Hi Alyssa,

    You can just put the problem into my solver, following the link at the top of the page, and it’ll solve it for you. I actually just did so, and got:

    2 5 6 3 1 8 4 9 7
    1 9 7 6 2 4 8 3 5
    4 3 8 7 5 9 2 1 6
    8 7 9 2 3 1 5 6 4
    6 2 5 4 9 7 1 8 3
    3 1 4 5 8 6 7 2 9
    9 6 2 8 4 5 3 7 1
    5 8 1 9 7 3 6 4 2
    7 4 3 1 6 2 9 5 8

    Like

  4. I have a little Neopets help site and Neopets created the game Roodoku which is their version of Sudoku. I was hoping to find a free script that I could host myself for my visitors to use to solve the puzzles for them. I found the source code to this, but I’m not a programmer and can’t get it to work. 😦

    I’ve seen the online version though, and it’s a blessing!

    Like

  5. This puzzle won’t solve because it times out with Firefox. Any suggestions?
    –9 –6 4–
    –3 — -7-
    -2- -8- —
    1– 5– –6
    -8- 2– -3-
    7– — –9
    — -4- -8-
    -5- — 1–
    –6 9– 2–
    Thanks,
    Bob E

    Like

  6. Unfortunately, there seem to be a few puzzles for which my algorithm is not ideal — in technical terms, it needs to do the “bound” part of the branch and bound algorithm sooner. I’ve thought of a few ways to achieve this … and then ran out of energy. Sorry. But it works for nearly all other puzzles.

    Like

  7. Nope, sorry — you could of course re-code mine, but it’s actually not very efficient in its current form, it prunes the branches a little late.

    Like

  8. …quick question not related to the sudoku but rather to php, are there any php video tutorials/awesome php books that you may recommend to someone who’s good at programming in java?

    Like

  9. Hi
    I’ve found another run timeout error
    on the f_1_1_1 put value=2
    then f_8_9_9 put value=2 too

    It leads me to error.. would you explain or fix it?

    Thanks

    Like

Comments are closed.