Example #1
0
 def test_unique_array_sum_combinations(self):
     A = [1, 2, 3, 3]
     B = [2, 3, 3, 4]
     C = [2, 3, 3, 4]
     target = 7
     answer = [(2, 3, 2), (3, 2, 2), (1, 2, 4),
               (1, 4, 2), (2, 2, 3), (1, 3, 3)]
     answer.sort()
     self.assertListEqual(sorted(unique_array_sum_combinations(A, B, C, target)), answer)
Example #2
0
 def test_unique_array_sum_combinations(self):
     A = [1, 2, 3, 3]
     B = [2, 3, 3, 4]
     C = [2, 3, 3, 4]
     target = 7
     answer = [(2, 3, 2), (3, 2, 2), (1, 2, 4),
               (1, 4, 2), (2, 2, 3), (1, 3, 3)]
     answer.sort()
     self.assertListEqual(sorted(unique_array_sum_combinations(A, B, C, target)), answer)
Example #3
0
from algorithms.backtrack import array_sum_combinations, unique_array_sum_combinations

A = [1, 2, 3, 3]
B = [2, 3, 3, 4]
C = [2, 3, 3, 4]
target = 7

print(array_sum_combinations(A, B, C, 7))

print(unique_array_sum_combinations(A, B, C, 7))