Exemplo n.º 1
0
        public CellGroup GetGrid(int gridNumber)
        {
            if (gridNumber < 0 || gridNumber > 8)
            {
                throw new ArgumentOutOfRangeException("gridNumber", "gridNumber must be between 0 and 8");
            }


            int currentCell = GridStartCells[gridNumber];

            CellGroup group     = new CellGroup();
            int       groupCell = 0;

            for (int y = 0; y < 3; y++)
            {
                for (int x = 0; x < 3; x++)
                {
                    group.Cells[groupCell] = this.Cells[currentCell];
                    groupCell++;
                    currentCell += 1;
                }
                currentCell += 6;
            }
            return(group);
        }
Exemplo n.º 2
0
 private static SodukuBoard CalculatePossibleValuesForRows(SodukuBoard board)
 {
     for (int i = 0; i < 9; i++)
     {
         CellGroup row = board.GetRow(i);
         row.SetPossibleValues();
     }
     return(board);
 }
Exemplo n.º 3
0
 private static SodukuBoard CalculatePossibleValuesForColumns(SodukuBoard board)
 {
     for (int i = 0; i < 9; i++)
     {
         CellGroup column = board.GetColumn(i);
         column.SetPossibleValues();
     }
     return(board);
 }
Exemplo n.º 4
0
 private static SodukuBoard CalculatePossibleValuesForGrids(SodukuBoard board)
 {
     for (int i = 0; i < 9; i++)
     {
         CellGroup grid = board.GetGrid(i);
         grid.SetPossibleValues();
     }
     return(board);
 }
Exemplo n.º 5
0
        public CellGroup GetColumn(int columnNumber)
        {
            if (columnNumber < 0 || columnNumber > 8)
            {
                throw new ArgumentOutOfRangeException("columnNumber", "columnNumber must be between 0 and 8");
            }

            CellGroup group       = new CellGroup();
            int       currentCell = columnNumber;

            for (int i = 0; i < 9; i++)
            {
                group.Cells[i] = this.Cells[currentCell];
                currentCell   += 9;
            }
            return(group);
        }
Exemplo n.º 6
0
        public CellGroup GetRow(int rowNumber)
        {
            if (rowNumber < 0 || rowNumber > 8)
            {
                throw new ArgumentOutOfRangeException("rowNumber", "rowNumber must be between 0 and 8");
            }

            int firstCell = rowNumber * 9;

            CellGroup group = new CellGroup();

            for (int i = 0; i < 9; i++)
            {
                group.Cells[i] = this.Cells[firstCell + i];
            }
            return(group);
        }