Example #1
0
    public static IEnumerable <(int, int)> Calculate(int[,] matrix)
    {
        for (var row = 0; row < matrix.RowCount(); row++)
        {
            for (var col = 0; col < matrix.ColumnCount(); col++)
            {
                if (IsSaddlePoint(row, col))
                {
                    yield return(row + 1, col + 1);
                }
            }
        }

        bool IsSaddlePoint(int row, int col)
        {
            var value = matrix[row, col];

            return(matrix.Row(row).All(n => n <= value) &&
                   matrix.Column(col).All(n => n >= value));
        }
    }