|
Links to
Sudoku; or algorithms
1,
2,
3, or
4, or
5,
userguide
or download
Installation
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.
Sudoku Solver
To set up the Sudoku solver, run the
following scripts in sqlplus:
@solver/sudoku_setup.sql -- creates tables and loads up static
data.
@solver/p_solve_sudoku.sql --
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
following script:
@qd_runtime/qda_deploy_install.sql
To set up the QDA procedures used by the Delphi
front end application, run the following scripts:
@frontend/qda_install_all.sql
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
puzzles..
solver/suoku.xls
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
tool):
insert into puzzles values (11,'The Times:
Fiendish',SYSDATE);
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
(11,5,'','7','2','','','','8','1','');
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');
commit;
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:
begin
p_solve_sudoku(11,3);
end;
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
algorithm.
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
button.
Patrick Barel:
Many kind thanks to Patrick Barel at
Bar Solutions
for writing this front end screen using
Qnxo and Delphi.
Patrick was responsible for the front end screens of Steven
Feuerstein's Qnxo
active mentoring software product for PL/SQL.
Oracle PL/SQL
|