Пример #1
0
def is_valid(check_slice, to_check):
    return find_sum_pair(check_slice, to_check)
Пример #2
0
 def test_PuzzleInput(self):
     numbers = [1721, 979, 366, 299, 675, 1456]
     self.assertListEqual(find_sum_pair(numbers, 2020), [299, 1721])
Пример #3
0
def find_product(numbers: list):
    [low, high] = find_sum_pair(numbers, 2020)
    return low * high
Пример #4
0
 def test_NoPair(self):
     self.assertIsNone(find_sum_pair([1, 2, 3], -1))
Пример #5
0
 def test_MiddleAndLast_SortRequired(self):
     numbers = [13, 23, 17, 1, 3, 2, 5, 7, 11]
     backupNumbers = copy.copy(numbers)
     self.assertListEqual(find_sum_pair(numbers, 16), [3, 13])
     self.assertListEqual(numbers, backupNumbers)
Пример #6
0
 def test_MiddleAndLast(self):
     numbers = [1, 2, 3, 5, 7, 11, 13, 17, 23]
     self.assertListEqual(find_sum_pair(numbers, 16), [3, 13])
Пример #7
0
 def test_FirstAndLast(self):
     self.assertListEqual(find_sum_pair([1, 2, 3, 7], 8), [1, 7])
Пример #8
0
 def test_Last(self):
     self.assertListEqual(find_sum_pair([1, 2, 3, 4], 7), [3, 4])
Пример #9
0
 def test_First(self):
     self.assertListEqual(find_sum_pair([1, 2, 3, 4], 3), [1, 2])
Пример #10
0
 def test_EmptyList(self):
     self.assertRaises(ListTooShort, lambda: find_sum_pair([], 0))
     self.assertRaises(ListTooShort, lambda: find_sum_pair([0], 0))