Cody

Solution 556600

Submitted on 13 Jan 2015 by Lukas
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))

pos = 2 3 5 possum = 10 lv = 2 pos = 2 3 2 5 3 5 possum = 5 7 8 index = 3 index_numbers = 3 5 number_index = 2 3 ind = 2 3

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

pos = 5 3 2 possum = 10 lv = 2 pos = 5 3 5 2 3 2 possum = 8 7 5 lv = 1 pos = 5 3 2 possum = 5 3 2 index = 3 index_numbers = 2 number_index = 3 ind = 3

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

pos = 2 3 5 possum = 10 lv = 2 pos = 2 3 2 5 3 5 possum = 5 7 8 lv = 1 pos = 2 3 5 possum = 2 3 5 lv = 0

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

pos = 1 1 1 1 1 possum = 5 index = 1 index_numbers = 1 1 1 1 1 number_index = 1 2 3 4 5 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))

pos = 1 2 3 4 100 possum = 110 lv = 4 pos = 1 2 3 4 1 2 3 100 1 2 4 100 1 3 4 100 2 3 4 100 possum = 10 106 107 108 109 lv = 3 pos = 1 2 3 1 2 4 1 2 100 1 3 4 1 3 100 1 4 100 2 3 4 2 3 100 2 4 100 3 4 100 possum = 6 7 103 8 104 105 9 105 106 107 lv = 2 pos = 1 2 1 3 1 4 1 100 2 3 2 4 2 100 3 4 3 100 4 100 possum = 3 4 5 101 5 6 102 7 103 104 lv = 1 pos = 1 2 3 4 100 possum = 1 2 3 4 100 index = 5 index_numbers = 100 number_index = 5 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))

pos = -7 -3 -2 8 5 possum = 1 lv = 4 pos = -7 -3 -2 8 -7 -3 -2 5 -7 -3 8 5 -7 -2 8 5 -3 -2 8 5 possum = -4 -7 3 4 8 lv = 3 pos = -7 -3 -2 -7 -3 8 -7 -3 5 -7 -2 8 -7 -2 5 -7 8 5 -3 -2 8 -3 -2 5 -3 8 5 -2 8 5 possum = -12 -2 -5 -1 -4 6 3 0 10 11 index = 8 index_numbers = -3 -2 5 number_index = 2 3 5 ind = 2 3 5