def test_combination_sum(self):
        candidates1 = [2, 3, 6, 7]
        target1 = 7
        answer1 = [[2, 2, 3], [7]]
        self.assertEqual(combination_sum(candidates1, target1), answer1)

        candidates2 = [2, 3, 5]
        target2 = 8
        answer2 = [[2, 2, 2, 2], [2, 3, 3], [3, 5]]
        self.assertEqual(combination_sum(candidates2, target2), answer2)
Beispiel #2
0
    def test_combination_sum(self):
        candidates1 = [2, 3, 6, 7]
        target1 = 7
        answer1 = [
            [2, 2, 3],
            [7]
        ]
        self.assertEqual(combination_sum(candidates1, target1), answer1)

        candidates2 = [2, 3, 5]
        target2 = 8
        answer2 = [
            [2, 2, 2, 2],
            [2, 3, 3],
            [3, 5]
        ]
        self.assertEqual(combination_sum(candidates2, target2), answer2)
Beispiel #3
0
from algorithms.backtrack import combination_sum

a = [2, 3, 6, 7]
target = 7

print(combination_sum(a, target))

## 박제준 4/14