Cody

# Problem 42992. S-T-R-E-T-C-H I-T O-U-T

Solution 1151575

Submitted on 1 Apr 2017 by H M Dipu Kabir
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 = [1 5 2 4 3];n=1; y_correct = [1 3 5 3.5 2 3 4 3.5 3]; assert(isequal(stretch_it_out(x,n),y_correct))

z = 1 3 5 z = 5.0000 3.5000 2.0000 z = 2 3 4 z = 4.0000 3.5000 3.0000 y = 1.0000 3.0000 5.0000 3.5000 2.0000 3.0000 4.0000 3.5000 3.0000

2   Pass
x = [1 5 2 4 3];n=2; y_correct=[1 2+1/3 3+2/3 5 4 3 2 2+2/3 3+1/3 4 3+2/3 3+1/3 3]; y=abs(stretch_it_out(x,n)-y_correct); assert(max(y)<1e-9)

z = 1.0000 2.3333 3.6667 5.0000 z = 5 4 3 2 z = 2.0000 2.6667 3.3333 4.0000 z = 4.0000 3.6667 3.3333 3.0000 y = 1.0000 2.3333 3.6667 5.0000 4.0000 3.0000 2.0000 2.6667 3.3333 4.0000 3.6667 3.3333 3.0000

3   Pass
k=ceil(5*rand)+1 x=1:k:121 n=k-1; assert(isequal(stretch_it_out(x,n),1:121))

k = 5 x = 1 6 11 16 21 26 31 36 41 46 51 56 61 66 71 76 81 86 91 96 101 106 111 116 121 z = 1 2 3 4 5 6 z = 6 7 8 9 10 11 z = 11 12 13 14 15 16 z = 16 17 18 19 20 21 z = 21 22 23 24 25 26 z = 26 27 28 29 30 31 z = 31 32 33 34 35 36 z = 36 37 38 39 40 41 z = 41 42 43 44 45 46 z = 46 47 48 49 50 51 z = 51 52 53 54 55 56 z = 56 57 58 59 60 61 z = 61 62 63 64 65 66 z = 66 67 68 69 70 71 z = 71 72 73 74 75 76 z = 76 77 78 79 80 81 z = 81 82 83 84 85 86 z = 86 87 88 89 90 91 z = 91 92 93 94 95 96 z = 96 97 98 99 100 101 z = 101 102 103 104 105 106 z = 106 107 108 109 110 111 z = 111 112 113 114 115 116 z = 116 117 118 119 120 121 y = Columns 1 through 29 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 Columns 30 through 58 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 Columns 59 through 87 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 Columns 88 through 116 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 Columns 117 through 121 117 118 119 120 121

4   Pass
x=[1 -1 1 -1 1 -1 1];n=3; y_correct=[1 0.5 0 -0.5 -1 -0.5 0 0.5 1 0.5 0 -0.5 -1 -0.5 0 0.5 1 0.5 0 -0.5 -1 -0.5 0 0.5 1]; assert(isequal(stretch_it_out(x,n),y_correct))

z = 1.0000 0.5000 0 -0.5000 -1.0000 z = -1.0000 -0.5000 0 0.5000 1.0000 z = 1.0000 0.5000 0 -0.5000 -1.0000 z = -1.0000 -0.5000 0 0.5000 1.0000 z = 1.0000 0.5000 0 -0.5000 -1.0000 z = -1.0000 -0.5000 0 0.5000 1.0000 y = Columns 1 through 17 1.0000 0.5000 0 -0.5000 -1.0000 -0.5000 0 0.5000 1.0000 0.5000 0 -0.5000 -1.0000 -0.5000 0 0.5000 1.0000 Columns 18 through 25 0.5000 0 -0.5000 -1.0000 -0.5000 0 0.5000 1.0000