A data structure could be a mapping from each of the N*N cells to the
three regions it belongs to, and then for each region, a set of N bits
indicating which values it already contains. Then the validation
simply involves iterating over the cells. For each one, if any of the
three regions already contain the value of that cell, validation
fails. Otherwise, set the bit for that value in the three regions.

A more challenging problem:

Given an unsolved Sudoku puzzle with some given cells and some unknown
cells, either indicate that there is no solution, provide the one
unique solution, or report that there are multiple solutions and
provide one example.

Don

On May 28, 1:23 am, Dumanshu <duman...@gmail.com> wrote:
> Given a n by n matrix. Suggest an algorithm to verify its correctness
> given a configuration. User can enter numbers only between 1 to n.
> I need this in 2 ways -
> 1. for the n by n matrix, suggest an elegant way for validating it.
> 2. suggest a data structure for this sudoku so that the structure aids
> in its verification.
>
> thnx for the help.

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to