Well I'm writing this for fun, no it's not homework.
So anyway, it's basically a Sudoku Solver.
I intend to have it solve a Sudoku by finding obvious pairs;
As in naked pairs : Solving Sudoku
That's a naked pair; A cell with only 1 possible number.
So far I have a Cell class, and withing that class I have a method that creates 81 instances of itself:
And then it occured to me;
How on Earth would I assign it values;
I was brainstorming, and thought that perhaps there could be a method that scans a row, returns an array of the nonzero numbers in the row, same for the column, and a 3*3 region, or box.
I'm not sure how I would code that, seeing as I am a O.K. programmer, I could use a little help, and if someone could just help me out by giving me some idea on how to do this, code etc, that would be great!
This is not homework, I code in my free time. Help would be very appreciated
import java.util.ArrayList; public class Cell { boolean isnull=false; int value; int xloc; int yloc; int possiblevalues[] = new int[] {1,2,3,4,5,6,7,8,9}; Cell[] cellarray = new Cell[81]; ArrayList signs = new ArrayList(40); public void assignvaluesandloc(){ int x = 0; Cell[] cellarray = new Cell[81]; GetDataMethods g = new GetDataMethods(); int currentnumber = 0; for (int row = 0; row <= 8; row++) { for(int col = 0; col <= 8; col++) { cellarray[x] = new Cell(); cellarray[x].value=g.newboard[row][col]; cellarray[x].xloc=row; cellarray[x].yloc=col; x++; } } } public void getcellvalue(){ } }