Cody

Solution 1451340

Submitted on 27 Feb 2018 by Jiahang Li
  • Size: 18
  • This is the leading solution.
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
x = 6; N = 3; y = buildSumArray(x,N); y2 = unique(y); assert(isequal(round(sum(y)*100)/100,x)) assert(isequal(length(y),N)) assert(isequal(length(y2),N)) assert(sum(y == 0) == 0) assert(isempty(y(y < 0)))

2   Pass
x = 13; N = 5; y = buildSumArray(x,N); y2 = unique(y); assert(isequal(round(sum(y)*100)/100,x)) assert(isequal(length(y),N)) assert(isequal(length(y2),N)) assert(sum(y == 0) == 0) assert(isempty(y(y < 0)))

3   Pass
x = 78; N = 11; y = buildSumArray(x,N); y2 = unique(y); assert(isequal(round(sum(y)*100)/100,x)) assert(isequal(length(y),N)) assert(isequal(length(y2),N)) assert(sum(y == 0) == 0) assert(isempty(y(y < 0)))

4   Pass
x = 2689; N = 245; y = buildSumArray(x,N); y2 = unique(y); assert(isequal(round(sum(y)*100)/100,x)) assert(isequal(length(y),N)) assert(isequal(length(y2),N)) assert(sum(y == 0) == 0) assert(isempty(y(y < 0)))