Cody

# Problem 42318. Evened up (or not)

Solution 671083

Submitted on 18 May 2015
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   Fail
%% 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))

Assertion failed.

4   Fail
%% 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))

Assertion failed.

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

Assertion failed.

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

Assertion failed.

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

Matrix dimensions must agree.

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

Matrix dimensions must agree.

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

Matrix dimensions must agree.

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

Matrix dimensions must agree.

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

Matrix dimensions must agree.

12   Fail
%% 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))

Matrix dimensions must agree.

13   Fail
%% 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))

Matrix dimensions must agree.

14   Fail
%% 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))

Matrix dimensions must agree.

### Community Treasure Hunt

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

Start Hunting!