Cody

# Problem 43. Subset Sum

Solution 1163369

Submitted on 14 Apr 2017
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

### Test Suite

Test Status Code Input and Output
1   Pass
v = [2, 3, 5]; n = 8; correct = [2, 3]; actual = subset_sum(v, n); assert(isequal(actual, correct))

binIdx = '111' binIdx = '110' binIdx = '101' binIdx = '100' binIdx = '011' 2 3 Name Size Bytes Class Attributes aaa 1x2 16 double bbb 0x0 0 double ind = 2 3

2   Pass
v = [5, 3, 2]; n = 2; correct = 3; actual = subset_sum(v, n); assert(isequal(actual, correct))

binIdx = '111' binIdx = '110' binIdx = '101' binIdx = '100' binIdx = '011' binIdx = '010' binIdx = '001' 3 Name Size Bytes Class Attributes aaa 1x1 8 double bbb 0x0 0 double ind = 3

3   Fail
v = [2, 3, 5]; n = 4; correct = []; actual = subset_sum(v, n); assert(isequal(actual, correct))

binIdx = '111' binIdx = '110' binIdx = '101' binIdx = '100' binIdx = '011' binIdx = '010' binIdx = '001' binIdx = '000' Name Size Bytes Class Attributes aaa 1x0 0 double bbb 0x0 0 double ind = 1×0 empty double row vector

Assertion failed.

4   Pass
v = [1, 1, 1, 1, 1]; n = 5; correct = [1, 2, 3, 4, 5]; actual = subset_sum(v, n); assert(isequal(actual, correct))

binIdx = '11111' 1 2 3 4 5 Name Size Bytes Class Attributes aaa 1x5 40 double bbb 0x0 0 double ind = 1 2 3 4 5

5   Pass
v = [1, 2, 3, 4, 100]; n = 100; correct = 5; actual = subset_sum(v, n); assert(isequal(actual, correct))

binIdx = '11111' binIdx = '11110' binIdx = '11101' binIdx = '11100' binIdx = '11011' binIdx = '11010' binIdx = '11001' binIdx = '11000' binIdx = '10111' binIdx = '10110' binIdx = '10101' binIdx = '10100' binIdx = '10011' binIdx = '10010' binIdx = '10001' binIdx = '10000' binIdx = '01111' binIdx = '01110' binIdx = '01101' binIdx = '01100' binIdx = '01011' binIdx = '01010' binIdx = '01001' binIdx = '01000' binIdx = '00111' binIdx = '00110' binIdx = '00101' binIdx = '00100' binIdx = '00011' binIdx = '00010' binIdx = '00001' 5 Name Size Bytes Class Attributes aaa 1x1 8 double bbb 0x0 0 double ind = 5

6   Pass
v = [-7, -3, -2, 8, 5]; n = 0; correct = [2, 3, 5]; actual = subset_sum(v, n); assert(isequal(actual, correct))

binIdx = '11111' binIdx = '11110' binIdx = '11101' binIdx = '11100' binIdx = '11011' binIdx = '11010' binIdx = '11001' binIdx = '11000' binIdx = '10111' binIdx = '10110' binIdx = '10101' binIdx = '10100' binIdx = '10011' binIdx = '10010' binIdx = '10001' binIdx = '10000' binIdx = '01111' binIdx = '01110' binIdx = '01101' 2 3 5 Name Size Bytes Class Attributes aaa 1x3 24 double bbb 0x0 0 double ind = 2 3 5