Code covered by the BSD License  

Highlights from
Fast Sudoku Solver

image thumbnail
from Fast Sudoku Solver by Yue Wu
An algorithm to mimic human solving procedure for Sudoku puzzles

sudoku_comflick(I,cell_ind)
function T = sudoku_comflick(I,cell_ind)

[x,y] = ind2sub([9,9],cell_ind);
bocmap = [1 1 1 2 2 2 3 3 3];
rown = numel(find(I(x,:) == I(cell_ind)));
Tr = rown>1;

if Tr == 1
    T = 1;
else
    coln = numel(find(I(:,y) == I(cell_ind)));
    Tc = coln>1;
    if Tc == 1
        T = 1;
    else
        boc = I((bocmap(x)-1)*3+1:bocmap(x)*3,(bocmap(y)-1)*3+1:bocmap(y)*3);
        bocn = numel(find(boc == I(cell_ind)));
        Tb = bocn>1;
        if Tb == 1
            T = 1;
        else
            T = 0;
        end
    end
end



    

Contact us at files@mathworks.com