コード例 #1
0
        public SudokuSolver(SudokuGrid grid)
        {
            if (grid == null)
                throw new ArgumentNullException();

            _grid = new SudokuGrid(grid);
        }
コード例 #2
0
        public Cell(SudokuGrid grid, int x, int y)
        {
            if (x < 0 || x > 8 || y < 0 || y > 8)
                throw new IndexOutOfRangeException();

            _grid = grid;
            _x = x;
            _y = y;
            _value = null;
        }
コード例 #3
0
        static void Main(string[] args)
        {
            int?[] grid = {5,3,null,null,7,null,null,null,null,
                           6, null,null,1,9,5,null,null,null,
                           null,9,8,null,null,null,null,6,null,
                           8,null,null,null,6,null,null,null,3,
                           4,null,null,8,null,3,null,null,1,
                           7,null,null,null,2,null,null,null,6,
                           null,6,null,null,null,null,2,8,null,
                           null,null,null,4,1,9,null,null,5,
                           null,null,null,null,8,null,null,7,9};
            SudokuGrid grid2 = new SudokuGrid(grid);
            SudokuSolver solver = new SudokuSolver(grid2);

            Console.WriteLine(solver.solve());

            Console.ReadLine();
        }
コード例 #4
0
        public SudokuGrid(SudokuGrid grid)
        {
            if (grid == null)
                throw new ArgumentNullException();

            _cells = new List<Cell>(9 * 9);

            for (int x = 0; x < 9; x++)
            {
                for (int y = 0; y < 9; y++)
                {
                    Cell cell = new Cell(this, grid.Get(x, y).Value, x, y);
                    _cells.Add(cell);
                }
            }
        }
コード例 #5
0
 public Cell(SudokuGrid grid, int? value, int x, int y)
     : this(grid, x, y)
 {
     _value = value;
 }