35 int32_t nelement = in_arr.size();
36 uint64_t count_of_subset = 0;
38 for (int32_t i = 0; i < (1 << (nelement)); i++) {
40 for (int32_t j = 0; j < nelement; j++) {
49 return count_of_subset;
60 std::cout <<
"1st test ";
61 std::vector<int32_t> array1 = {-7, -3, -2, 5, 8};
62 assert(backtracking::subset_sum::number_of_subsets(0, array1) ==
65 std::cout <<
"passed" << std::endl;
68 std::cout <<
"2nd test ";
69 std::vector<int32_t> array2 = {1, 2, 3, 3};
70 assert(backtracking::subset_sum::number_of_subsets(6, array2) ==
73 std::cout <<
"passed" << std::endl;
76 std::cout <<
"3rd test ";
77 std::vector<int32_t> array3 = {1, 1, 1, 1};
78 assert(backtracking::subset_sum::number_of_subsets(1, array3) ==
81 std::cout <<
"passed" << std::endl;
84 std::cout <<
"4th test ";
85 std::vector<int32_t> array4 = {3, 3, 3, 3};
86 assert(backtracking::subset_sum::number_of_subsets(6, array4) ==
89 std::cout <<
"passed" << std::endl;
92 std::cout <<
"5th test ";
93 std::vector<int32_t> array5 = {};
94 assert(backtracking::subset_sum::number_of_subsets(6, array5) ==
97 std::cout <<
"passed" << std::endl;