Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sudokus on an interactive page 2

Status
Not open for further replies.

sinbadly

Technical User
Mar 16, 2006
126
GB
Is it possible to code an interactive page for a sudoku puzzle, please, experts?
 
yes.

you need javascript to make it work smoothly. you can either code the whole thing in js or use php and then use javascript to interact with the PHP script through AJAX.

of course you could also code the whole thing in java or flash too, but then this is a php forum!
 
That's terrific, Justin. Many thanks indeed. To my shame, I'm not familiar with java. It's one of those things I plan to become more knowledgeable about. But this looks excellent, and I will busy myself with it, and hopefully get it tamed for my use.

Another great thing you have helped me with. It's appreciated very much. All the best
paul
 
Here is working generator code:
Tested it only on difficulty level 3.

Notes:
+ The function only generates the integers; you'll have to build your own interface.
+ make this the last statement of the function:
return array($puzzle, $solution);
so the call becomes:
list($puzzle, $solution) = generate(3);
+ $puzzle and $solution are strings of comma separated integers. Difficulty level 3 returns 81 integers in $solution, while in the puzzle an amount of these are left out.
$apuzzle = explode(',', $puzzle); makes it an array.
Every 9 elements start a new row in the 9 x 9 sudoku grid.
 
Thanks very much, binarshi. I have it now and will test it tonight. Looks very good.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top