Beispiel #1
0
    def test_handle_impossible_length_for_adjacent_cells(self):
        '''
        Test that a message is returned when length for adjacent cells is to long
        '''
        data = [[1,2],
                [2,3]]
        length = 3

        result = find_product(data,length)

        self.assertEqual(result, 'Not possible to calculate product from 3 adjacent cells')
Beispiel #2
0
    def test_find_product_small(self):
        '''
        Test that it can find the largest product for small grid
        '''
        data = [[1,2],
                [2,3]]
        length = 2

        result = find_product(data,length)

        self.assertEqual(result, 6)
Beispiel #3
0
    def test_find_product_small_length_one(self):
        '''
        Test that it can find the largest product for small grid where number of adjacent numbers should be 1
        '''
        data = [[1,2],
                [2,3]]
        length = 1

        result = find_product(data,length)

        self.assertEqual(result, 3)
Beispiel #4
0
    def test_find_product_medium(self):
        '''
        Test that it can find the largest product for medium grid
        '''
        data = [[1, 2, 3, 4],
                [2, 3, 4, 5],
                [3, 4, 5, 6],
                [4, 5, 6, 7]]

        length = 3

        result = find_product(data,length)

        self.assertEqual(result, 210)
Beispiel #5
0
    def test_find_product_large(self):
        '''
        Test that it can find the largest product for large grid
        '''
        data = [[8, 2, 22, 97, 38, 15, 0, 40, 0, 75],
                [49, 49, 99, 40, 17, 81, 18, 57, 60, 87],
                [81, 49, 31, 73, 55, 79, 14, 29, 93, 71],
                [52, 70, 95, 23, 4, 60, 11, 42, 69, 24],
                [22, 31, 16, 71, 51, 67, 63, 89, 41, 92],
                [24, 47, 32, 60, 99, 3, 45, 2, 44, 75],
                [32, 98, 81, 28, 64, 23, 67, 10, 26, 38],
                [67, 26, 20, 68, 2, 62, 12, 20, 95, 63],
                [24, 55, 58, 5, 66, 73, 99, 26, 97, 17],
                [21, 36, 23, 9, 75, 0, 76, 44, 20, 45]]

        length = 3

        result = find_product(data,length)

        self.assertEqual(result, 667755)