Cody

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

Solution 1582927

Submitted on 13 Jul 2018 by goc3
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)))

ans = 1.9000 2.0000 2.1000

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

ans = 2.5000 2.5500 2.6000 2.6500 2.7000

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

ans = 6.9909 7.0109 7.0309 7.0509 7.0709 7.0909 7.1109 7.1309 7.1509 7.1709 7.1909

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

ans = Columns 1 through 17 10.8755 10.8763 10.8771 10.8780 10.8788 10.8796 10.8804 10.8812 10.8821 10.8829 10.8837 10.8845 10.8853 10.8862 10.8870 10.8878 10.8886 Columns 18 through 34 10.8894 10.8903 10.8911 10.8919 10.8927 10.8935 10.8944 10.8952 10.8960 10.8968 10.8976 10.8985 10.8993 10.9001 10.9009 10.9017 10.9026 Columns 35 through 51 10.9034 10.9042 10.9050 10.9058 10.9067 10.9075 10.9083 10.9091 10.9099 10.9108 10.9116 10.9124 10.9132 10.9140 10.9149 10.9157 10.9165 Columns 52 through 68 10.9173 10.9181 10.9190 10.9198 10.9206 10.9214 10.9222 10.9231 10.9239 10.9247 10.9255 10.9263 10.9271 10.9280 10.9288 10.9296 10.9304 Columns 69 through 85 10.9312 10.9321 10.9329 10.9337 10.9345 10.9353 10.9362 10.9370 10.9378 10.9386 10.9394 10.9403 10.9411 10.9419 10.9427 10.9435 10.9444 Columns 86 through 102 10.9452 10.9460 10.9468 10.9476 10.9485 10.9493 10.9501 10.9509 10.9517 10.9526 10.9534 10.9542 10.9550 10.9558 10.9567 10.9575 10.9583 Columns 103 through 119 10.9591 10.9599 10.9608 10.9616 10.9624 10.9632 10.9640 10.9649 10.9657 10.9665 10.9673 10.9681 10.9690 10.9698 10.9706 10.9714 10.9722 Columns 120 through 136 10.9731 10.9739 10.9747 10.9755 10.9763 10.9771 10.9780 10.9788 10.9796 10.9804 10.9812 10.9821 10.9829 10.9837 10.9845 10.9853 10.9862 Columns 137 through 153 10.9870 10.9878 10.9886 10.9894 10.9903 10.9911 10.9919 10.9927 10.9935 10.9944 10.9952 10.9960 10.9968 10.9976 10.9985 10.9993 11.0001 Columns 154 through 170 11.0009 11.0017 11.0026 11.0034 11.0042 11.0050 11.0058 11.0067 11.0075 11.0083 11.0091 11.0099 11.0108 11.0116 11.0124 11.0132 11.0140 Columns 171 through 187 11.0149 11.0157 11.0165 11.0173 11.0181 11.0190 11.0198 11.0206 11.0214 11.0222 11.0231 11.0239 11.0247 11.0255 11.0263 11.0271 11.0280 Columns 188 through 204 11.0288 11.0296 11.0304 11.0312 11.0321 11.0329 11.0337 11.0345 11.0353 11.0362 11.0370 11.0378 11.0386 11.0394 11.0403 11.0411 11.0419 Columns 205 through 221 11.0427 11.0435 11.0444 11.0452 11.0460 11.0468 11.0476 11.0485 11.0493 11.0501 11.0509 11.0517 11.0526 11.0534 11.0542 11.0550 11.0558 Columns 222 through 238 11.0567 11.0575 11.0583 11.0591 11.0599 11.0608 11.0616 11.0624 11.0632 11.0640 11.0649 11.0657 11.0665 11.0673 11.0681 11.0690 11.0698 Columns 239 through 245 11.0706 11.0714 11.0722 11.0731 11.0739 11.0747 11.0755

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!