コード例 #1
0
    def test_up_down_or_right_very_small_cases(self):
        m = numpy.array([
            [10, 20,  6,  7],
            [ 1,  2,  9, 30],
            [10,  3,  4, 30],
        ])
        expected = sum([1, 2, 9, 6, 7])
        self.assertEqual(calculate_matrix_minimal_path_sum_up_down_or_right(m), expected)

        m = numpy.array([
            [10, 11, 12,  9],
            [ 9,  1,  1, 10],
            [ 8, 13, 14,  8],
        ])
        self.assertEqual(calculate_matrix_minimal_path_sum_up_down_or_right(m), 9 + 1 + 1 + 10)
コード例 #2
0
 def test_up_down_or_right_large_matrix(self):
     m = numpy.loadtxt('matrix.txt', dtype=numpy.int32, delimiter=',')
     self.assertEqual(calculate_matrix_minimal_path_sum_up_down_or_right(m), 260324)