class SudokuGrid { private GridSquare[,] GridCell = new GridSquare[10,10]; private int[,] GridRefs = { { 1, 1 }, { 1, 4 }, { 1, 7 }, { 4, 1 }, { 4, 4 }, { 4, 7 }, { 7, 1 }, { 7, 4 }, { 7, 7 } }; public SudokuGrid() { for (int i = 1; i <= 9; i++) { for (int j = 1; j <= 9; j++) { GridCell[i, j] = new GridSquare(i, j); } } } public GridSquare this[int i, int j] { get { return GridCell[i, j]; } } public void EnterItem(int row, int col, int cellvalue) { GridCell[row, col].Value = cellvalue; //eliminate from columns and rows for (int i = 1; i <= 9; i++) { if (i != row) { GridCell[row, i][cellvalue] = 1; } if (i != col) { GridCell[i,col][cellvalue] = 1; } } //eliminate from minisquares for (int i = GridRefs[GridCell[row, col].MiniSquare, 0]; i <= GridRefs[GridCell[row, col].MiniSquare, 0] + 2; i++) { for (int j = GridRefs[GridCell[row, col].MiniSquare, 1]; j <= GridRefs[GridCell[row, col].MiniSquare, 1] + 2; j++) { GridCell[i, j][cellvalue] = 1; } } } }