public void Given_grid_1_1_When_find_min_Then_return()
        {
            var grid = new int[1, 1];

            grid[0, 0] = 1;

            Assert.AreEqual(1, MinimumPathSum.MinPathSum(grid));
        }
Exemple #2
0
        public void Case0()
        {
            var grid = new int[1][];

            grid[0] = new[] { 1, 2, 3 };

            var pathSummer = new MinimumPathSum();

            Assert.Equal(6, pathSummer.MinPathSum(grid));
        }
Exemple #3
0
        public void Case2()
        {
            var grid = new int[2][];

            grid[0] = new[] { 1, 1, 3 };
            grid[1] = new[] { 3, 1, 1 };

            var pathSummer = new MinimumPathSum();

            Assert.Equal(4, pathSummer.MinPathSum(grid));
        }
Exemple #4
0
        public void Case3()
        {
            var grid = new int[3][];

            grid[0] = new[] { 1, 3, 1 };
            grid[1] = new[] { 1, 5, 1 };
            grid[2] = new[] { 4, 2, 1 };

            var pathSummer = new MinimumPathSum();

            Assert.Equal(7, pathSummer.MinPathSum(grid));
        }
Exemple #5
0
        public void Test3()
        {
            //Given
            int[][] input = new int[0][];

            //When
            var sut = new MinimumPathSum();
            int num = sut.MinPathSum(input);

            //Then
            num.Should().Be(0);
        }
        public void Given_grid_When_find_min_Then_return()
        {
            var grid = new int[2, 3];

            grid[0, 0] = 1;
            grid[0, 1] = 2;
            grid[0, 2] = 3;
            grid[1, 0] = 4;
            grid[1, 1] = 5;
            grid[1, 2] = 6;

            Assert.AreEqual(12, MinimumPathSum.MinPathSum(grid));
        }
Exemple #7
0
        public void Test5()
        {
            //Given
            int[][] input = new int[][] {
                new int[] { 9, 1, 4, 8 }
            };

            //When
            var sut = new MinimumPathSum();
            int num = sut.MinPathSum(input);

            //Then
            num.Should().Be(22);
        }
Exemple #8
0
        public void Test2()
        {
            //Given
            int[][] input = new int[][] {
                new int[] { 1, 1, 1 },
                new int[] { 1, 1, 1 },
                new int[] { 1, 1, 1 }
            };

            //When
            var sut = new MinimumPathSum();
            int num = sut.MinPathSum(input);

            //Then
            num.Should().Be(5);
        }