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);
    }
    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);
    }
Beispiel #3
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) };
Beispiel #4
0
 public void Saddle_point()
 {
     var values = new[,]
     {
         { 1, 2 },
         { 3, 4 }
     };
     var actual = new SaddlePoints(values).Calculate();
     Assert.That(actual, Is.EqualTo(new[] { Tuple.Create(0, 1) }));
 }
Beispiel #5
0
 public void No_saddle_point()
 {
     var values = new[,]
     {
         { 2, 1 },
         { 1, 2 }
     };
     var actual = new SaddlePoints(values).Calculate();
     Assert.That(actual, Is.Empty);
 }
Beispiel #6
0
    public void No_saddle_point()
    {
        var values = new[, ]
        {
            { 2, 1 },
            { 1, 2 }
        };
        var actual = new SaddlePoints(values).Calculate();

        Assert.That(actual, Is.Empty);
    }
Beispiel #7
0
 public void Another_saddle_point()
 {
     var values = new[,]
     {
         { 18,  3, 39, 19,  91 },
         { 38, 10,  8, 77, 320 },
         {  3,  4,  8,  6,   7 }
     };
     var actual = new SaddlePoints(values).Calculate();
     Assert.That(actual, Is.EqualTo(new[] { Tuple.Create(2, 2) }));
 }
Beispiel #8
0
 public void Readme_example()
 {
     var values = new[,]
     {
         { 9, 8, 7 },
         { 5, 3, 2 },
         { 6, 6, 7 }
     };
     var actual = new SaddlePoints(values).Calculate();
     Assert.That(actual, Is.EqualTo(new [] { Tuple.Create(1, 0)}));
 }
Beispiel #9
0
    public void Saddle_point()
    {
        var values = new[, ]
        {
            { 1, 2 },
            { 3, 4 }
        };
        var actual = new SaddlePoints(values).Calculate();

        Assert.That(actual, Is.EqualTo(new[] { Tuple.Create(0, 1) }));
    }
Beispiel #10
0
 public void Multiple_saddle_points()
 {
     var values = new[,]
     {
         { 4, 5, 4 },
         { 3, 5, 5 },
         { 1, 5, 4 }
     };
     var actual = new SaddlePoints(values).Calculate();
     Assert.That(actual, Is.EqualTo(new[] { Tuple.Create(0, 1), Tuple.Create(1, 1), Tuple.Create(2, 1) }));
 }
    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);
    }
Beispiel #13
0
    public void Another_saddle_point()
    {
        var values = new[, ]
        {
            { 18, 3, 39, 19, 91 },
            { 38, 10, 8, 77, 320 },
            { 3, 4, 8, 6, 7 }
        };
        var actual = new SaddlePoints(values).Calculate();

        Assert.That(actual, Is.EqualTo(new[] { Tuple.Create(2, 2) }));
    }
Beispiel #14
0
    public void Multiple_saddle_points()
    {
        var values = new[, ]
        {
            { 4, 5, 4 },
            { 3, 5, 5 },
            { 1, 5, 4 }
        };
        var actual = new SaddlePoints(values).Calculate();

        Assert.That(actual, Is.EqualTo(new[] { Tuple.Create(0, 1), Tuple.Create(1, 1), Tuple.Create(2, 1) }));
    }
Beispiel #15
0
    public void Readme_example()
    {
        var values = new[, ]
        {
            { 9, 8, 7 },
            { 5, 3, 2 },
            { 6, 6, 7 }
        };
        var actual = new SaddlePoints(values).Calculate();

        Assert.That(actual, Is.EqualTo(new [] { Tuple.Create(1, 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() };