Cody

Solution 744829

Submitted on 24 Sep 2015 by Peng Liu
  • Size: 7
  • This is the leading solution.
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
%% filetext = fileread('cumin.m'); assert(isempty(strfind(filetext,'cummin'))) assert(isempty(strfind(filetext,'cummax'))) assert(isempty(strfind(filetext,'feval')))

2   Pass
%% x = randi(100); assert(isequal(cumin(x),cummin(x))) assert(isequal(cumin(x,1),cummin(x,1))) assert(isequal(cumin(x,2),cummin(x,2))) assert(isequal(cumin(x,1,'reverse'),cummin(x,1,'reverse'))) assert(isequal(cumin(x,2,'reverse'),cummin(x,2,'reverse'))) assert(isequal(cumin(x,'reverse'),cummin(x,'reverse')))

y = 40 y = 40 y = 40 y = 40 y = 40 y = 40

3   Pass
%% x = randi(100,randi([2 100]),1); assert(isequal(cumin(x),cummin(x))) assert(isequal(cumin(x,1),cummin(x,1))) assert(isequal(cumin(x,2),cummin(x,2))) assert(isequal(cumin(x,1,'reverse'),cummin(x,1,'reverse'))) assert(isequal(cumin(x,2,'reverse'),cummin(x,2,'reverse'))) assert(isequal(cumin(x,'reverse'),cummin(x,'reverse')))

y = 33 33 33 33 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 y = 33 33 33 33 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 y = 33 68 95 54 4 36 38 91 74 8 78 55 53 86 7 43 16 27 30 22 2 10 22 32 74 73 25 3 24 13 47 15 3 65 74 75 95 24 88 70 2 82 73 29 31 78 100 51 52 79 51 20 33 12 49 39 y = 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 12 12 12 12 12 12 12 12 12 12 12 12 12 39 39 y = 33 68 95 54 4 36 38 91 74 8 78 55 53 86 7 43 16 27 30 22 2 10 22 32 74 73 25 3 24 13 47 15 3 65 74 75 95 24 88 70 2 82 73 29 31 78 100 51 52 79 51 20 33 12 49 39 y = 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 12 12 12 12 12 12 12 12 12 12 12 12 12 39 39

4   Pass
%% x = randi(100,1,randi([2 100])); assert(isequal(cumin(x),cummin(x))) assert(isequal(cumin(x,1),cummin(x,1))) assert(isequal(cumin(x,2),cummin(x,2))) assert(isequal(cumin(x,1,'reverse'),cummin(x,1,'reverse'))) assert(isequal(cumin(x,2,'reverse'),cummin(x,2,'reverse'))) assert(isequal(cumin(x,'reverse'),cummin(x,'reverse')))

y = Columns 1 through 16 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 Columns 17 through 32 7 7 7 7 7 7 7 7 7 6 6 6 6 6 6 6 Columns 33 through 48 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 Columns 49 through 64 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 y = Columns 1 through 16 7 28 48 44 94 96 47 59 97 40 36 59 62 26 24 35 Columns 17 through 32 89 62 31 22 92 53 30 22 41 6 60 24 80 84 59 68 Columns 33 through 48 10 90 23 75 33 53 86 66 7 10 38 96 31 35 47 76 Columns 49 through 64 37 41 34 76 90 30 62 80 44 81 80 75 47 83 17 19 y = Columns 1 through 16 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 Columns 17 through 32 7 7 7 7 7 7 7 7 7 6 6 6 6 6 6 6 Columns 33 through 48 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 Columns 49 through 64 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 y = Columns 1 through 16 7 28 48 44 94 96 47 59 97 40 36 59 62 26 24 35 Columns 17 through 32 89 62 31 22 92 53 30 22 41 6 60 24 80 84 59 68 Columns 33 through 48 10 90 23 75 33 53 86 66 7 10 38 96 31 35 47 76 Columns 49 through 64 37 41 34 76 90 30 62 80 44 81 80 75 47 83 17 19 y = Columns 1 through 16 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 Columns 17 through 32 6 6 6 6 6 6 6 6 6 6 7 7 7 7 7 7 Columns 33 through 48 7 7 7 7 7 7 7 7 7 10 17 17 17 17 17 17 Columns 49 through 64 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 19 y = Columns 1 through 16 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 Columns 17 through 32 6 6 6 6 6 6 6 6 6 6 7 7 7 7 7 7 Columns 33 through 48 7 7 7 7 7 7 7 7 7 10 17 17 17 17 17 17 Columns 49 through 64 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 19

5   Pass
%% x = magic(10); assert(isequal(cumin(x),cummin(x))) assert(isequal(cumin(x,1),cummin(x,1))) assert(isequal(cumin(x,2),cummin(x,2))) assert(isequal(cumin(x,1,'reverse'),cummin(x,1,'reverse'))) assert(isequal(cumin(x,2,'reverse'),cummin(x,2,'reverse'))) assert(isequal(cumin(x,'reverse'),cummin(x,'reverse')))

y = 92 99 1 8 15 67 74 51 58 40 92 80 1 8 15 67 55 51 58 40 4 80 1 8 15 54 55 51 58 40 4 80 1 8 3 54 55 51 58 28 4 80 1 2 3 54 55 51 52 28 4 24 1 2 3 42 49 26 33 28 4 5 1 2 3 42 30 26 33 28 4 5 1 2 3 29 30 26 33 28 4 5 1 2 3 29 30 26 33 28 4 5 1 2 3 29 30 26 27 28 y = 92 99 1 8 15 67 74 51 58 40 92 80 1 8 15 67 55 51 58 40 4 80 1 8 15 54 55 51 58 40 4 80 1 8 3 54 55 51 58 28 4 80 1 2 3 54 55 51 52 28 4 24 1 2 3 42 49 26 33 28 4 5 1 2 3 42 30 26 33 28 4 5 1 2 3 29 30 26 33 28 4 5 1 2 3 29 30 26 33 28 4 5 1 2 3 29 30 26 27 28 y = 92 92 1 1 1 1 1 1 1 1 98 80 7 7 7 7 7 7 7 7 4 4 4 4 4 4 4 4 4 4 85 85 19 19 3 3 3 3 3 3 86 86 25 2 2 2 2 2 2 2 17 17 17 17 17 17 17 17 17 17 23 5 5 5 5 5 5 5 5 5 79 6 6 6 6 6 6 6 6 6 10 10 10 10 10 10 10 10 10 10 11 11 11 11 11 11 11 11 11 11 y = 4 5 1 2 3 29 30 26 27 28 4 5 7 2 3 29 30 26 27 28 4 5 13 2 3 29 30 26 27 28 10 5 13 2 3 29 30 26 27 28 10 5 13 2 9 29 30 26 27 34 10 5 13 77 78 29 30 26 27 53 10 5 13 77 78 29 30 32 27 53 10 6 13 77 78 29 31 38 27 53 10 12 94 77 78 35 37 44 27 53 11 18 100 77 84 36 43 50 27 59 y = 1 1 1 8 15 40 40 40 40 40 7 7 7 14 16 41 41 41 41 41 4 20 20 20 22 47 47 47 47 47 3 3 3 3 3 28 28 28 28 28 2 2 2 2 9 34 34 34 34 34 17 24 26 26 26 26 26 26 33 65 5 5 30 30 30 30 30 32 39 66 6 6 13 29 29 29 31 38 45 72 10 12 35 35 35 35 37 44 46 53 11 18 27 27 27 27 27 27 27 59 y = 4 5 1 2 3 29 30 26 27 28 4 5 7 2 3 29 30 26 27 28 4 5 13 2 3 29 30 26 27 28 10 5 13 2 3 29 30 26 27 28 10 5 13 2 9 29 30 26 27 34 10 5 13 77 78 29 30 26 27 53 10 5 13 77 78 29 30 32 27 53 10 6 13 77 78 29 31 38 27 53 10 12 94 77 78 35 37 44 27 53 11 18 100 77 84 36 43 50 27 59

6   Pass
%% x = []; assert(isequal(cumin(x),cummin(x))) assert(isequal(cumin(x,1),cummin(x,1))) assert(isequal(cumin(x,2),cummin(x,2))) assert(isequal(cumin(x,1,'reverse'),cummin(x,1,'reverse'))) assert(isequal(cumin(x,2,'reverse'),cummin(x,2,'reverse'))) assert(isequal(cumin(x,'reverse'),cummin(x,'reverse')))

y = [] y = [] y = [] y = [] y = [] y = []