Thread: Java and Sudoku
View Single Post
Old 12-07-2006, 12:24 PM   #6 (permalink)
Kallian
CHARLIE DON'T SURF!
 
Kallian's Avatar
 
Join Date: Jul 2004
Posts: 779
+0 Internets
You could scan a row/col for 1-9, adding up the total number of each number like so:

int [] check = new int[9];

as you scan a row, keep track of totals like:
check[n - 1]++;

where n is the number you just read in.

check[0] would contain the total number of 1s.
check[1] would contain the total number of 2s.
etc.

if each element in the array is 1, then you're good, else, you're not.
__________________
In Soviet Russia, Exception throws you!
Kallian is offline   Reply With Quote

 
Uberguilds Network