Exemplo n.º 1
0
    public void Can_identify_that_empty_matrix_has_no_saddle_points()
    {
        var input  = new int[, ] {
        };
        var sut    = new SaddlePoints(input);
        var actual = sut.Calculate();

        Assert.Empty(actual);
    }
Exemplo n.º 2
0
 public void Can_identify_single_saddle_point()
 {
     var matrix = new[, ]
     {
         { 9, 8, 7 },
         { 5, 3, 2 },
         { 6, 6, 7 }
     };
     var actual   = SaddlePoints.Calculate(matrix);
     var expected = new[] { (2, 1) };
    public void Can_identify_lack_of_saddle_points_when_there_are_none()
    {
        var input = new[, ] {
            { 1, 2, 3 }, { 3, 1, 2 }, { 2, 3, 1 }
        };
        var sut    = new SaddlePoints(input);
        var actual = sut.Calculate();

        Assert.Empty(actual);
    }
    public void Can_identify_saddle_point_in_bottom_right_corner()
    {
        var input = new[, ] {
            { 8, 7, 9 }, { 6, 7, 6 }, { 3, 2, 5 }
        };
        var sut      = new SaddlePoints(input);
        var actual   = sut.Calculate();
        var expected = new[] { Tuple.Create(2, 2) };

        Assert.Equal(expected, actual);
    }
    public void Can_identify_multiple_saddle_points()
    {
        var input = new[, ] {
            { 4, 5, 4 }, { 3, 5, 5 }, { 1, 5, 4 }
        };
        var sut      = new SaddlePoints(input);
        var actual   = sut.Calculate();
        var expected = new[] { Tuple.Create(0, 1), Tuple.Create(1, 1), Tuple.Create(2, 1) };

        Assert.Equal(expected, actual);
    }
Exemplo n.º 6
0
    public void Can_identify_single_saddle_point()
    {
        var input = new[, ]
        {
            { 9, 8, 7 },
            { 5, 3, 2 },
            { 6, 6, 7 }
        };
        var sut      = new SaddlePoints(input);
        var actual   = sut.Calculate();
        var expected = new[] { Tuple.Create(1, 0) };

        Assert.Equal(expected, actual);
    }
    public void Can_identify_saddle_point_in_large_matrix()
    {
        var input = new int[1000, 1000];

        for (var i = 0; i < input.GetLength(0); i++)
        {
            for (var j = 0; j < input.GetLength(1); j++)
            {
                input[i, j] = (i + 1) * (j + 1);
            }
        }

        var sut      = new SaddlePoints(input);
        var actual   = sut.Calculate();
        var expected = new[] { (0, input.GetLength(1) - 1).ToTuple() };