Problem Statement
- The main goal of this task is to implement three generic functions:
valid_sum
,sum_of_one
andsum_of_all
. - The
valid_sum
is kind of a helper function which will create an array of valid non-negative intergers from the given 2d matrix. - One of the primary functions is
sum_of_one
, which computes all the possible subsets from an array of non-negative integers whose sum is equal to the provided integer sum. - Next comes the final function which is
sum_of_all
. This function computes all the possible subsets from an array of non-negative integers whose sum is equal to all valid non-negative integer elements from the given 2d matrix.
actually I’m getting these errors in test
Compiling 1 file (.ex)
1) test check all expected sum of subsets for given array and matrix of sum (Task1aSumOfSubsetsTest)
test/task1a_sum_of_subsets_test.exs:110
** (ArgumentError) the Access calls for keywords expect the key to be an atom, got: 12
code: Enum.map(expected_sum_of_all_matrix, fn ({k, v}) -> checkThreeCondtions(sum_of_all_result[k],k,array_of_digits,v) end)
stacktrace:
(elixir 1.13.4) lib/access.ex:310: Access.get/3
test/task1a_sum_of_subsets_test.exs:156: anonymous fn/2 in Task1aSumOfSubsetsTest."test check all expected sum of subsets for given array and matrix of sum"/1
(elixir 1.13.4) lib/enum.ex:1597: anonymous fn/3 in Enum.map/2
(stdlib 4.0) maps.erl:411: :maps.fold_1/3
(elixir 1.13.4) lib/enum.ex:2408: Enum.map/2
test/task1a_sum_of_subsets_test.exs:156: (test)
.
2) test checks all the expected sum of subsets for given array with one element as zero and matrix of sum (Task1aSumOfSubsetsTest)
test/task1a_sum_of_subsets_test.exs:162
** (ArgumentError) the Access calls for keywords expect the key to be an atom, got: 12
code: Enum.map(expected_sum_of_all_matrix, fn ({k, v}) -> checkThreeCondtions(sum_of_all_result[k], k , array_of_digits,v) end)
stacktrace:
(elixir 1.13.4) lib/access.ex:310: Access.get/3
test/task1a_sum_of_subsets_test.exs:206: anonymous fn/2 in Task1aSumOfSubsetsTest."test checks all the expected sum of subsets for given array with one element as zero and matrix of sum"/1
(elixir 1.13.4) lib/enum.ex:1597: anonymous fn/3 in Enum.map/2
(stdlib 4.0) maps.erl:411: :maps.fold_1/3
(elixir 1.13.4) lib/enum.ex:2408: Enum.map/2
test/task1a_sum_of_subsets_test.exs:206: (test)
..
3) test check valid sum for the given matrix (Task1aSumOfSubsetsTest)
test/task1a_sum_of_subsets_test.exs:40
Assertion with == failed
code: assert Task1aSumOfSubsets.valid_sum(matrix_of_sum) == expected_list_of_valid_sums
left: []
right: [21, 12, 12, 17, 22]
stacktrace:
test/task1a_sum_of_subsets_test.exs:49: (test)
...
Finished in 0.1 seconds (0.00s async, 0.1s sync)
9 tests, 3 failures
Randomized with seed 206453