Пример #1
0
        public override void Execute(int row, int col, int value, Board board)
        {
            // Ignore rule if not on diagonal
            if (row != col && row != 8 - col)
            {
                return;
            }

            // Top-left to bottom-right
            for (var i = 0; i < 9; i++)
            {
                if (i == row)
                {
                    continue;
                }

                board.MarkInvalid(i, i, value);
            }

            // Top-right to bottom-left
            for (var i = 0; i < 9; i++)
            {
                if (i == row)
                {
                    continue;
                }

                board.MarkInvalid(i, 8 - i, value);
            }
        }
Пример #2
0
        public override void Execute(int row, int col, int value, Board board)
        {
            for (var c = 0; c < 9; c++)
            {
                if (c == col)
                {
                    continue;
                }

                board.MarkInvalid(row, c, value);
            }
        }
Пример #3
0
        public override void Execute(int row, int col, int value, Board board)
        {
            for (var r = 0; r < 9; r++)
            {
                if (r == row)
                {
                    continue;
                }

                board.MarkInvalid(r, col, value);
            }
        }
Пример #4
0
        public override void Execute(int row, int col, int value, Board board)
        {
            // Determine top-left coords of box
            var startRow = (row / 3) * 3;
            var startCol = (col / 3) * 3;

            for (var rowOff = 0; rowOff < 3; rowOff++)
            {
                for (var colOff = 0; colOff < 3; colOff++)
                {
                    var r = startRow + rowOff;
                    var c = startCol + colOff;

                    if (r == row && c == col)
                    {
                        continue;
                    }

                    board.MarkInvalid(r, c, value);
                }
            }
        }