Cody

Solution 1774211

Submitted on 5 Apr 2019 by Paul Morant
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))

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

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

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

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

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

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

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

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

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

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

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

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

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