You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
assert(backtracking::subset_sum::subset_sum(0, array1) == 2); // first argument in subset_sum function is the required sum and second is the input array
64
62
std::cout << "passed" << std::endl;
65
63
66
64
// Test 2
67
65
std::cout << "2nd test ";
68
-
std::vector<uint64_t> array2 = {1, 2, 3, 3};
69
-
assert(backtracking::subset_sum::subset_sum(6, array2) == 3); // here we are expecting 3 subsets which sum up to 6 i.e.
70
-
// {(1,2,3),(1,2,3),(3,3)}
66
+
std::vector<int> array2 = {1, 2, 3, 3};
67
+
assert(backtracking::subset_sum::subset_sum(6, array2) == 3); // here we are expecting 3 subsets which sum up to 6 i.e. {(1,2,3),(1,2,3),(3,3)}
71
68
std::cout << "passed" << std::endl;
72
69
73
70
// Test 3
74
71
std::cout << "3rd test ";
75
-
std::vector<uint64_t> array3 = {1, 1, 1, 1};
76
-
assert(backtracking::subset_sum::subset_sum(1, array3) == 4); // here we are expecting 4 subsets which sum up to 1 i.e.
77
-
// {(1),(1),(1),(1)}
72
+
std::vector<int> array3 = {1, 1, 1, 1};
73
+
assert(backtracking::subset_sum::subset_sum(1, array3) == 4); // here we are expecting 4 subsets which sum up to 1 i.e. {(1),(1),(1),(1)}
78
74
std::cout << "passed" << std::endl;
79
75
80
76
// Test 4
81
77
std::cout << "4th test ";
82
-
std::vector<uint64_t> array4 = {3, 3, 3, 3};
83
-
assert(backtracking::subset_sum::subset_sum(6, array4) == 6); // here we are expecting 6 subsets which sum up to 6 i.e.
84
-
// {(3,3),(3,3),(3,3),(3,3),(3,3),(3,3)}
78
+
std::vector<int> array4 = {3, 3, 3, 3};
79
+
assert(backtracking::subset_sum::subset_sum(6, array4) == 6); // here we are expecting 6 subsets which sum up to 6 i.e. {(3,3),(3,3),(3,3),(3,3),(3,3),(3,3)}
85
80
std::cout << "passed" << std::endl;
86
81
87
82
// Test 5
88
83
std::cout << "5th test ";
89
-
std::vector<uint64_t> array5 = {};
84
+
std::vector<int> array5 = {};
90
85
assert(backtracking::subset_sum::subset_sum(6, array5) == 0); // here we are expecting 0 subsets which sum up to 6 i.e. we cannot select anything from an empty array
0 commit comments