Cody

Problem 42317. De-primed

Solution 1823497

Submitted on 23 May 2019 by David Legrand
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
M = 1:10; M_corr = [2,4,6,4,10,6,14,8,9,10]; assert(isequal(de_primed(M),M_corr))

M = 2 4 6 4 10 6 14 8 9 10

2   Pass
M = 20:3:50; M_corr = [20,46,26,58,32,35,38,82,44,94,50]; assert(isequal(de_primed(M),M_corr))

M = 20 46 26 58 32 35 38 82 44 94 50

3   Pass
M = 2:2:100; M_corr = [4 M(2:end)]; assert(isequal(de_primed(M),M_corr))

M = Columns 1 through 30 4 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46 48 50 52 54 56 58 60 Columns 31 through 50 62 64 66 68 70 72 74 76 78 80 82 84 86 88 90 92 94 96 98 100

4   Pass
M = 10:10:100; M_corr = M; assert(isequal(de_primed(M),M_corr))

M = 10 20 30 40 50 60 70 80 90 100

5   Pass
M = 3:3:100; M_corr = [6,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57,60,63,66,69,72,75,78,81,84,87,90,93,96,99]; assert(isequal(de_primed(M),M_corr))

M = Columns 1 through 30 6 6 9 12 15 18 21 24 27 30 33 36 39 42 45 48 51 54 57 60 63 66 69 72 75 78 81 84 87 90 Columns 31 through 33 93 96 99

6   Pass
M = eye(4); M_corr = 2*M; assert(isequal(de_primed(M),M_corr))

M = 2 0 0 0 0 2 0 0 0 0 2 0 0 0 0 2

7   Pass
M = magic(6); M_corr = [35, 2, 6,26,38,24; 6,32,14,21,46,25; 62, 9, 4,22,27,20; 8,28,33,34,10,15; 30,10,34,12,14,16; 4,36,58,26,18,22]; assert(isequal(de_primed(M),M_corr))

M = 35 2 6 26 38 24 6 32 14 21 46 25 62 9 4 22 27 20 8 28 33 34 10 15 30 10 34 12 14 16 4 36 58 26 18 22

8   Pass
ind = randi(4); switch ind case 1 M = 1:10; M_corr = [2,4,6,4,10,6,14,8,9,10]; case 2 M = eye(4); M_corr = 2*M; case 3 M = 10:10:100; M_corr = M; case 4 M = magic(6); M_corr = [35, 2, 6,26,38,24; 6,32,14,21,46,25; 62, 9, 4,22,27,20; 8,28,33,34,10,15; 30,10,34,12,14,16; 4,36,58,26,18,22]; end assert(isequal(de_primed(M),M_corr))

M = 35 2 6 26 38 24 6 32 14 21 46 25 62 9 4 22 27 20 8 28 33 34 10 15 30 10 34 12 14 16 4 36 58 26 18 22

9   Pass
ind = randi(4); switch ind case 1 M = 3:3:100; M_corr = [6,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57,60,63,66,69,72,75,78,81,84,87,90,93,96,99]; case 2 M = 1:10; M_corr = [2,4,6,4,10,6,14,8,9,10]; case 3 M = eye(4); M_corr = 2*M; case 4 M = 20:3:50; M_corr = [20,46,26,58,32,35,38,82,44,94,50]; end assert(isequal(de_primed(M),M_corr))

M = 2 0 0 0 0 2 0 0 0 0 2 0 0 0 0 2

10   Pass
ind = randi(4); switch ind case 1 M = 20:3:50; M_corr = [20,46,26,58,32,35,38,82,44,94,50]; case 2 M = 10:10:100; M_corr = M; case 3 M = 2:2:100; M_corr = [4 M(2:end)]; case 4 M = 1:10; M_corr = [2,4,6,4,10,6,14,8,9,10]; end assert(isequal(de_primed(M),M_corr))

M = Columns 1 through 30 4 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46 48 50 52 54 56 58 60 Columns 31 through 50 62 64 66 68 70 72 74 76 78 80 82 84 86 88 90 92 94 96 98 100

Suggested Problems

More from this Author139

Community Treasure Hunt

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

Start Hunting!