Cody

Solution 802603

Submitted on 7 Jan 2016 by David Schafer
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))

b = 2 3 5 s = 2 a = 1 k = 2 s = 5 a = 1 2 k = 3 s = 10 a = 1 2 3 k = 4 s = 3 a = 2 k = 3 s = 8 a = 2 3 c = 3 5 ind = 2 ind = 2 3

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

b = 2 3 5 s = 2 a = 1 c = 2 ind = 3

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

b = 2 3 5 s = 2 a = 1 k = 2 s = 5 a = 1 2 k = 3 s = 3 a = 2 k = 3 s = 8 a = 2 3 k = 4 s = 5 a = 3 k = 4

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))

b = 1 1 1 1 1 s = 1 a = 1 k = 2 s = 2 a = 1 2 k = 3 s = 3 a = 1 2 3 k = 4 s = 4 a = 1 2 3 4 k = 5 s = 5 a = 1 2 3 4 5 c = 1 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))

b = 1 2 3 4 100 s = 1 a = 1 k = 2 s = 3 a = 1 2 k = 3 s = 6 a = 1 2 3 k = 4 s = 10 a = 1 2 3 4 k = 5 s = 110 a = 1 2 3 4 5 k = 6 s = 2 a = 2 k = 3 s = 5 a = 2 3 k = 4 s = 9 a = 2 3 4 k = 5 s = 109 a = 2 3 4 5 k = 6 s = 3 a = 3 k = 4 s = 7 a = 3 4 k = 5 s = 107 a = 3 4 5 k = 6 s = 4 a = 4 k = 5 s = 104 a = 4 5 k = 6 s = 100 a = 5 c = 100 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))

b = -7 -3 -2 5 8 s = -7 a = 1 k = 2 s = -10 a = 1 2 k = 3 s = -12 a = 1 2 3 k = 4 s = -7 a = 1 2 3 4 k = 5 s = 1 a = 1 2 3 4 5 k = 6 s = -3 a = 2 k = 3 s = -5 a = 2 3 k = 4 s = 0 a = 2 3 4 c = -3 -2 5 ind = 2 ind = 2 3 ind = 2 3 5

Suggested Problems

More from this Author95