Cody

# Problem 42318. Evened up (or not)

Solution 2701547

Submitted on 16 Jul 2020 by Nikolaos Nikolaou
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; e = 1; M_corr = [2,2,4,4,6,6,8,8,10,10]; assert(isequal(evened_up(M,e),M_corr))

M = 2 2 4 4 6 6 8 8 10 10

2   Pass
M = 1:10; e = 0; M_corr = [1,3,3,5,5,7,7,9,9,11]; assert(isequal(evened_up(M,e),M_corr))

M = 1 3 3 5 5 7 7 9 9 11

3   Pass
M = 20:3:50; e = 1; M_corr = [20,24,26,30,32,36,38,42,44,48,50]; assert(isequal(evened_up(M,e),M_corr))

M = 20 24 26 30 32 36 38 42 44 48 50

4   Pass
M = 20:3:50; e = 0; M_corr = [21,23,27,29,33,35,39,41,45,47,51]; assert(isequal(evened_up(M,e),M_corr))

M = 21 23 27 29 33 35 39 41 45 47 51

5   Pass
M = 2:2:100; e = 1; M_corr = M; assert(isequal(evened_up(M,e),M_corr))

M = Columns 1 through 30 2 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

6   Pass
M = 2:2:100; e = 0; M_corr = M+1; assert(isequal(evened_up(M,e),M_corr))

M = Columns 1 through 30 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 51 53 55 57 59 61 Columns 31 through 50 63 65 67 69 71 73 75 77 79 81 83 85 87 89 91 93 95 97 99 101

7   Pass
M = ones(3); e = 1; M_corr = M*2; assert(isequal(evened_up(M,e),M_corr))

M = 2 2 2 2 2 2 2 2 2

8   Pass
M = magic(3); e = 0; M_corr = [9,1,7;3,5,7;5,9,3]; assert(isequal(evened_up(M,e),M_corr))

M = 9 1 7 3 5 7 5 9 3

9   Pass
M = magic(3); e = 1; M_corr = [8,2,6;4,6,8;4,10,2]; assert(isequal(evened_up(M,e),M_corr))

M = 8 2 6 4 6 8 4 10 2

10   Pass
M = eye(4); e = 1; M_corr = M*2; assert(isequal(evened_up(M,e),M_corr))

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

11   Pass
M = eye(4); e = 0; M_corr = ones(4); assert(isequal(evened_up(M,e),M_corr))

M = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1

12   Pass
ind = randi(4); switch ind case 1 M = 1:10; e = 1; M_corr = [2,2,4,4,6,6,8,8,10,10]; case 2 M = 20:3:50; e = 1; M_corr = [20,24,26,30,32,36,38,42,44,48,50]; case 3 M = ones(3); e = 1; M_corr = M*2; case 4 M = eye(4); e = 0; M_corr = ones(4); end assert(isequal(evened_up(M,e),M_corr))

M = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1

13   Pass
ind = randi(4); switch ind case 1 M = 2:2:100; e = 0; M_corr = M+1; case 2 M = 1:10; e = 0; M_corr = [1,3,3,5,5,7,7,9,9,11]; case 3 M = 1:10; e = 1; M_corr = [2,2,4,4,6,6,8,8,10,10]; case 4 M = magic(3); e = 0; M_corr = [9,1,7;3,5,7;5,9,3]; end assert(isequal(evened_up(M,e),M_corr))

M = 1 3 3 5 5 7 7 9 9 11

14   Pass
ind = randi(4); switch ind case 1 M = eye(4); e = 0; M_corr = ones(4); case 2 M = ones(3); e = 1; M_corr = M*2; case 3 M = 20:3:50; e = 1; M_corr = [20,24,26,30,32,36,38,42,44,48,50]; case 4 M = 2:2:100; e = 1; M_corr = M; end assert(isequal(evened_up(M,e),M_corr))

M = Columns 1 through 30 2 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

### Community Treasure Hunt

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

Start Hunting!