And then some … Ajax (buzz buzz!), valid xHTML, CSS Design and a mySQL database.
This article is written for my fellow students wanting to know more about this experiment.
A Sudoku is a 9*9 grid, made up of 3*3 subgrids called “regions”. Some cells already contain numbers. The goal is to fill in the empty cells, one number in each, so that each column, row, and region contains the numbers 1-9 exactly once. Each number in the solution therefore occurs only once in each of three “directions”. – From Wikipedia
The application tries to help solving a Sudoku by offering suggestions and/or trying to solve it automatically.
Some extra info about the tools I’ve used
- mySQL & phpMyAdmin: phpMyAdmin is a popular PHP-front end to administer a mySQL-database.
- PHP5: This new version of the popular scripting language offers better support for OOP. PHP5 allows for the following concepts to be used:
- public / private
- getters and setters
- Exception Handling
See the code below for examples.
How it works
This was no attempt to solve every Sudoku around and it’s not about maths either, so the algorithm used to “solve” Sudoku’s is actually quite simple; there are nine options for each box, the algorithm will see which one of those are still possible by checking the row, columns and region for numbers that are already there.
See a demo of this project. It’s tested in Firefox 1.5, but I’m told it’s working ok in Safari too.
One has gotta keep on learning, so I also tried to write my first real WebService using PHP and the new SOAP classes. The SOAPClient-class was used to open up the “give-me-a-sudoku-example”-function for the world. It takes one argument, a difficulty level from 1 to 3 and returns a string which represents a Sudoku. Maybe not very useful, but at least now I know how to publish and consume WebServices, right?
- (and Prototype / Scriptaculous / SOAPClient / Database class by Sven Wagener)