Calling all PHP programming Sudoku fans!

<![CDATA[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!

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.