Calling all PHP programming Sudoku fans!
I’ve been running a free Sudoku game for a couple of years at www.grantgibson.co.uk/sudoku. It’s available to play in desktop and mobile formats as well as on widget sites like Netvibes.com.
The Flash part is really my area of expertise, but I also had to hack together a PHP script to generate the puzzles. I found a script that does the right sort of thing, and modified it to output in my required format. However, over the years I’ve had a few people complain that it produces puzzles with multiple solutions (and then only accepts one of those solutions as the ‘correct’ answer).
I don’t know enough mathematics or PHP to correct the problem, so I’m putting out an appeal. If anyone wants to have a go at correcting the problem — or rewriting the script — please do so. You’ll be helping me and thousands of other Sudoku fans around the world.
Requirements
Input parameters (via GET URL):
- Difficulty [currently 1, 2 or 3, but can be tweaked if necessary]
- Random [currently a six digit integer, but can be tweaked if necessary]
Output format (plain text):
puzzle=<TITLE>
Daily Random Sudoku: Medium
<AUTHOR>
Your Name Here
<COPYRIGHT>
Your Name Here and Grant Gibson
<DIFFICULTY>
2
<GRID>
.ooo..o..
o.o..oooo
o.o…ooo
o.o..oooo
oo.ooo.oo
oooo..o.o
ooo…o.o
oooo..o.o
..o..ooo.
<ANSWER>
528631974
163974285
497285631
235716849
671849352
984352716
859123467
312467598
746598123
… where answer is the unique grid solution, and grid represents the intial state of the puzzle - dot for blank, o for a displayed number.
I’ve attached the Current Grid Script here. If you’d like to suggest any revisions, or post up an alternative version of the code please do so — either as a comment here, or directly to me by email. See my contact page for email details.
Thanks, and good luck!

I think I’ve got a Perl script to generate them somewhere. Though why have a unique result why now simply have your Falsh front end check to see if the solution is valid as opposed to matching it to a set answer. That way if there are more than one answer it still works.
Just a thought.
Comment by Simon — February 25, 2008 @ 2:28 pm
Hi Simon - Yeah, allowing multiple solutions would be an option, but I think Sudoku purists frown on that kind of thing. Carol Vorderman hosted a programme once about Sudoku and her grid had two solutions. Apparently she was getting grief about it for ages afterwards.
Also, the system at the moment will check a partial solution for you, which wouldn’t be possible if it could accomodate multiple solutions (unless I built in some proper sudoku-solving AI in there).
If you do happen to have a perl script that generates single-solution grids somewhere, please fire it over my way!
Comment by grant — February 28, 2008 @ 9:37 pm