Oracle PL/SQL Sudoku Solver

2. Singles - box

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

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

5. Full Member Set


webmaster@db-innovations.co.uk : Copyright 2005 - 2010 Database Innovations Ltd : Last modified: 27/08/10