Cody

# Problem 44531. 2) Are you more familiar with iteration methods or Linear Algebra ? Let's see together.

Solution 1449491

Submitted on 26 Feb 2018 by David Verrelli
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)))

d = 1 y = 1 2 3

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

d = 0.8000 y = 1.0000 1.8000 2.6000 3.4000 4.2000

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

d = 1.2182 y = 1.0000 2.2182 3.4364 4.6545 5.8727 7.0909 8.3091 9.5273 10.7455 11.9636 13.1818

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

d = 0.0818 y = Columns 1 through 18 1.0000 1.0818 1.1635 1.2453 1.3271 1.4088 1.4906 1.5724 1.6541 1.7359 1.8177 1.8994 1.9812 2.0630 2.1447 2.2265 2.3083 2.3900 Columns 19 through 36 2.4718 2.5536 2.6353 2.7171 2.7989 2.8806 2.9624 3.0442 3.1259 3.2077 3.2895 3.3712 3.4530 3.5348 3.6165 3.6983 3.7801 3.8618 Columns 37 through 54 3.9436 4.0254 4.1071 4.1889 4.2707 4.3524 4.4342 4.5160 4.5977 4.6795 4.7613 4.8430 4.9248 5.0066 5.0883 5.1701 5.2519 5.3336 Columns 55 through 72 5.4154 5.4972 5.5789 5.6607 5.7425 5.8242 5.9060 5.9878 6.0695 6.1513 6.2331 6.3148 6.3966 6.4784 6.5601 6.6419 6.7237 6.8054 Columns 73 through 90 6.8872 6.9690 7.0507 7.1325 7.2143 7.2960 7.3778 7.4596 7.5413 7.6231 7.7049 7.7866 7.8684 7.9502 8.0319 8.1137 8.1954 8.2772 Columns 91 through 108 8.3590 8.4407 8.5225 8.6043 8.6860 8.7678 8.8496 8.9313 9.0131 9.0949 9.1766 9.2584 9.3402 9.4219 9.5037 9.5855 9.6672 9.7490 Columns 109 through 126 9.8308 9.9125 9.9943 10.0761 10.1578 10.2396 10.3214 10.4031 10.4849 10.5667 10.6484 10.7302 10.8120 10.8937 10.9755 11.0573 11.1390 11.2208 Columns 127 through 144 11.3026 11.3843 11.4661 11.5479 11.6296 11.7114 11.7932 11.8749 11.9567 12.0385 12.1202 12.2020 12.2838 12.3655 12.4473 12.5291 12.6108 12.6926 Columns 145 through 162 12.7744 12.8561 12.9379 13.0197 13.1014 13.1832 13.2650 13.3467 13.4285 13.5103 13.5920 13.6738 13.7556 13.8373 13.9191 14.0009 14.0826 14.1644 Columns 163 through 180 14.2462 14.3279 14.4097 14.4915 14.5732 14.6550 14.7368 14.8185 14.9003 14.9821 15.0638 15.1456 15.2274 15.3091 15.3909 15.4727 15.5544 15.6362 Columns 181 through 198 15.7180 15.7997 15.8815 15.9633 16.0450 16.1268 16.2086 16.2903 16.3721 16.4539 16.5356 16.6174 16.6992 16.7809 16.8627 16.9445 17.0262 17.1080 Columns 199 through 216 17.1898 17.2715 17.3533 17.4351 17.5168 17.5986 17.6804 17.7621 17.8439 17.9257 18.0074 18.0892 18.1710 18.2527 18.3345 18.4163 18.4980 18.5798 Columns 217 through 234 18.6616 18.7433 18.8251 18.9069 18.9886 19.0704 19.1522 19.2339 19.3157 19.3975 19.4792 19.5610 19.6428 19.7245 19.8063 19.8881 19.9698 20.0516 Columns 235 through 245 20.1334 20.2151 20.2969 20.3787 20.4604 20.5422 20.6240 20.7057 20.7875 20.8693 20.9510