The Oracle at Delphi, Oracle HQ in California, and the grid technology of Oracle 10g

Sudoku

Bloggers:

You might be interested in some of the blog entries on this Oracle PL/SQL Sudoku solver:

Steven Feuerstein

Patrick Barel

Forum:

Sudoku Forum

Codetips:

Need some help with building some Oracle PL/SQL solutions? Then these articles may be of use...

1. Dynamic SQL: A performance tuning guide.

2. Bulk Data Loading: The available approaches.

3. Report Writing: Using Oracle XML, XSL, and HTML.

4. Data Driven Processing: XML Metadata

 

 

Oracle PL/SQL Sudoku Solver - Algorithms

Links to Sudoku; or algorithms 1, 2, 3, or 4, userguide or download

2. Singles - box

If there is only a single remaining pencil mark in a box for a given number (there may be other pencil mark in its cell), then it must be a certainty, and all other pencil marks in that cell can be rubbed out. All other pencil marks in the same box, row, or column can also be rubbed out.

In the above example the numbers in red are single candidates in a box. The blue numbers can then be rubbed out.

UPDATE  answers
SET     pencil_mark_ind = 0
WHERE   pencil_mark_ind > 0
AND     puzzle_id = p_puzzle_id
AND    (box_id, answer) IN
    (   SELECT  a.box_id,
                a.answer
        FROM    answers a
        WHERE   a.puzzle_id = p_puzzle_id
        AND     a.pencil_mark_ind > 0
        GROUP BY a.box_id,
                a.answer
        HAVING COUNT(*) = 1);
 

Like with the Singles Cell algorithm, if any certainties have been identified, then any candidates that can be eliminated need to be rubbed out using the same two steps described before.

Just by iterating through the Singles - Cell and Singles - Box steps over and over again, it possible to solve a good proportion of the puzzle (see below). Anything less than a "The Times Fiendish" will usually be completely solved with these two algorithms.

The above shows how far the above puzzle can get just on these two algorithms.

To view the other algorithms select the required link...

1. Singles - Cell

2. Singles -Box

3. Cross Hatching

4. Partial Members Set

Oracle PL/SQL Sudoku Solver Oracle PL/SQL Sudoku Solver Oracle PL/SQL Sudoku Solver Oracle PL/SQL Sudoku Solver Oracle PL/SQL Oracle PL/SQL

Send mail to webmaster@db-innovations.co.uk with questions or comments about this web site.
Copyright © 2004 Database Innovations Limited
Last modified: 26/10/05