Cody

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

Solution 2883491

Submitted on 27 Aug 2020 by Ramesh Kumar V
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))

m = 5 y = [] x1 = 2 z = 1 3 5 y = 1 3 x1 = -1.5000 z = 5.0000 3.5000 2.0000 y = 1.0000 3.0000 5.0000 3.5000 x1 = 1 z = 2 3 4 y = 1.0000 3.0000 5.0000 3.5000 2.0000 3.0000 x1 = -0.5000 z = 4.0000 3.5000 3.0000 y = 1.0000 3.0000 5.0000 3.5000 2.0000 3.0000 4.0000 3.5000 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)

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

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

m = 7 y = [] x1 = -0.5000 z = 1.0000 0.5000 0 -0.5000 -1.0000 y = 1.0000 0.5000 0 -0.5000 x1 = 0.5000 z = -1.0000 -0.5000 0 0.5000 1.0000 y = 1.0000 0.5000 0 -0.5000 -1.0000 -0.5000 0 0.5000 x1 = -0.5000 z = 1.0000 0.5000 0 -0.5000 -1.0000 y = 1.0000 0.5000 0 -0.5000 -1.0000 -0.5000 0 0.5000 1.0000 0.5000 0 -0.5000 x1 = 0.5000 z = -1.0000 -0.5000 0 0.5000 1.0000 y = 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 x1 = -0.5000 z = 1.0000 0.5000 0 -0.5000 -1.0000 y = Columns 1 through 18 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 0.5000 Columns 19 through 20 0 -0.5000 x1 = 0.5000 z = -1.0000 -0.5000 0 0.5000 1.0000 y = Columns 1 through 18 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 0.5000 Columns 19 through 24 0 -0.5000 -1.0000 -0.5000 0 0.5000 y = Columns 1 through 18 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 0.5000 Columns 19 through 25 0 -0.5000 -1.0000 -0.5000 0 0.5000 1.0000

Suggested Problems

More from this Author80

Community Treasure Hunt

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

Start Hunting!