Sudoku; or algorithms
Retrieve the zip
file download and extract it
into a folder of your choice. Make sure to retain the folder
structure inside the zip file.
To set up the Sudoku solver, run the
following scripts in sqlplus:
@solver/sudoku_setup.sql -- creates tables and loads up static
compiles the procedure
Front End Screen
The front end application developed by
Patrick Barel is optional, but provides
a very basic, but effective Windows frontend to the solver.
To set up the additional front end screen,
first the Qnxo QD runtime packages must be installed by running the
To set up the QDA procedures used by the Delphi
front end application, run the following scripts:
In an ideal installation, the QD runtime being
a common component, would be best installed in a separate schema.
This would require the appropriate synonyms and grants being set up.
Running The Solver
Command Line Mode
An Excel spreadsheet input form has been
supplied to help with the input and subsequent manipulation of
Open up the spreadsheet and type in the puzzle
into the top entry form. A unique puzzle number must be given to the
puzzle, and also a brief description.
Copy and paste the insert statements generated
in the right hand side box into sqlplus (or other SQL command line
insert into puzzles values (11,'The Times:
insert into puzzle_load values (11,1,'6','','','','','','1','4','');
insert into puzzle_load values (11,2,'','','1','5','','','','','3');
insert into puzzle_load values (11,3,'','','','','','9','','6','8');
insert into puzzle_load values (11,4,'','','','','','1','','7','');
insert into puzzle_load values
insert into puzzle_load values (11,6,'','3','','6','','','','','');
insert into puzzle_load values (11,7,'9','1','','3','','','','','');
insert into puzzle_load values (11,8,'3','','','','','2','7','','');
insert into puzzle_load values (11,9,'','8','4','','','','','','5');
The puzzle is now loaded into the staging table
in the database and ready to be solved.
To solve the puzzle run the following anonymous
PL/SQL block command from sqlplus:
The first parameter is the unique puzzle id
entered above in the spreadsheet. The second parameter controls the
amount of feedback given during the calculation.
1 - Minimal - shows summary of algorithms used
and the number of iterations.
2 - Shows a summary of the candidates after each iteration.
3 - Very detailed - shows the candidates and certainties after each
The output is via DBMS_OUTPUT, and for the most
difficult puzzles it is advisable to set the serveroutput size to
the maximum (1Mb). Click
here to see an example output at the lowest setting.
Front End Screen
The front end screen is invoked by running the
sudoku.exe executable in the frontend folder.
Select File from the main menu, then
Logon to connect to the database.
For a new puzzle, enter the puzzle id and the
puzzle description into the fields annotated with the red Puzzle
Header Entry label on the screenshot below. This will insert an
entry into the puzzles table.
Then enter the puzzle numbers into the grid
annotated with the red Puzzle Entry label. This will insert
the puzzle data in the puzzle_load table (as per the insert
statements in the command line approach).
Click on the Solve button to save the
data and execute the solver.
The solution is displayed in the bottom grid
and the puzzle will now appear in the puzzle selection list.
To re-run previously entered puzzles, select
the puzzle from the puzzle selection list and click on the Solve
Many kind thanks to Patrick Barel at
for writing this front end screen using
Qnxo and Delphi.
Patrick was responsible for the front end screens of Steven
active mentoring software product for PL/SQL.