Cody

# Problem 42631. Cumulative minimum of an array

Solution 1695941

Submitted on 19 Dec 2018
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 = 55 y = 55 y = 55 y = 55 y = 55 y = 55

3   Fail
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 = 25 y = 25 4 y = 25 4 4 y = 25 4 4 4 y = 25 4 4 4 4 y = 25 4 4 4 4 4 y = 25 4 4 4 4 4 4 y = 25 4 4 4 4 4 4 4 y = 25 4 4 4 4 4 4 4 4 y = 25 4 4 4 4 4 4 4 4 4 y = 25 4 4 4 4 4 4 4 4 4 4 y = 25 4 4 4 4 4 4 4 4 4 4 2 y = 25 4 4 4 4 4 4 4 4 4 4 2 2 y = 25 4 4 4 4 4 4 4 4 4 4 2 2 2 y = 25 4 4 4 4 4 4 4 4 4 4 2 2 2 2 y = 25 4 4 4 4 4 4 4 4 4 4 2 2 2 2 2 y = 25 4 4 4 4 4 4 4 4 4 4 2 2 2 2 2 2 y = 25 4 4 4 4 4 4 4 4 4 4 2 2 2 2 2 2 2 y = 25 4 4 4 4 4 4 4 4 4 4 2 2 2 2 2 2 2 2 y = 25 4 4 4 4 4 4 4 4 4 4 2 2 2 2 2 2 2 2 2 y = 25 4 4 4 4 4 4 4 4 4 4 2 2 2 2 2 2 2 2 2 2 y = 25 4 4 4 4 4 4 4 4 4 4 2 2 2 2 2 2 2 2 2 2 2 y = 25 4 4 4 4 4 4 4 4 4 4 2 2 2 2 2 2 2 2 2 2 2 2 y = 25 4 4 4 4 4 4 4 4 4 4 2 2 2 2 2 2 2 2 2 2 2 2 2 y = 25 4 4 4 4 4 4 4 4 4 4 2 2 2 2 2 2 2 2 2 2 2 2 2 2 y = 25 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 y = 25 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 y = 25 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 y = 25 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 y = 25 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 y = Columns 1 through 30 25 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 Column 31 2 y = Columns 1 through 30 25 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 Columns 31 through 32 2 2 y = Columns 1 through 30 25 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 Columns 31 through 33 2 2 2 y = Columns 1 through 30 25 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 Columns 31 through 34 2 2 2 2 y = Columns 1 through 30 25 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 Columns 31 through 35 2 2 2 2 2 y = Columns 1 through 30 25 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 Columns 31 through 36 2 2 2 2 2 2 y = Columns 1 through 30 25 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 Columns 31 through 37 2 2 2 2 2 2 2 y = Columns 1 through 30 25 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 Columns 31 through 38 2 2 2 2 2 2 2 2 y = Columns 1 through 30 25 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 Columns 31 through 39 2 2 2 2 2 2 2 2 2 y = Columns 1 through 30 25 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 Columns 31 through 40 2 2 2 2 2 2 2 2 2 2 y = Columns 1 through 30 25 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 Columns 31 through 41 2 2 2 2 2 2 2 2 2 2 2 y = Columns 1 through 30 25 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 Columns 31 through 42 2 2 2 2 2 2 2 2 2 2 2 2 y = Columns 1 through 30 25 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 Columns 31 through 43 2 2 2 2 2 2 2 2 2 2 2 2 2 y = Columns 1 through 30 25 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 Columns 31 through 44 2 2 2 2 2 2 2 2 2 2 2 2 2 2 y = Columns 1 through 30 25 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 Columns 31 through 45 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 y = Columns 1 through 30 25 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 Columns 31 through 46 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 y = Columns 1 through 30 25 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 Columns 31 through 47 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 y = Columns 1 through 30 25 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 Columns 31 through 48 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 y = Columns 1 through 30 25 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 Columns 31 through 49 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 y = Columns 1 through 30 25 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 Columns 31 through 50 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 y = Columns 1 through 30 25 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 Columns 31 through 51 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 y = Columns 1 through 30 25 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 Columns 31 through 52 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 y = Columns 1 through 30 25 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 ...

Assertion failed.

4   Fail
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 = 56 y = 56 56 y = 56 56 19 y = 56 56 19 8 y = 56 56 19 8 8 y = 56 56 19 8 8 8 y = 56 56 19 8 8 8 8 y = 56 56 19 8 8 8 8 8 y = 56 56 19 8 8 8 8 8 8 y = 56 56 19 8 8 8 8 8 8 8 y = 56 56 19 8 8 8 8 8 8 8 8 y = 56 56 19 8 8 8 8 8 8 8 8 8 y = 56 56 19 8 8 8 8 8 8 8 8 8 7 y = 56 56 19 8 8 8 8 8 8 8 8 8 7 7 y = 56 56 19 8 8 8 8 8 8 8 8 8 7 7 6 y = 56 56 19 8 8 8 8 8 8 8 8 8 7 7 6 6 y = 56 56 19 8 8 8 8 8 8 8 8 8 7 7 6 6 6 y = 56 56 19 8 8 8 8 8 8 8 8 8 7 7 6 6 6 6 y = 56 56 19 8 8 8 8 8 8 8 8 8 7 7 6 6 6 6 6 y = 56 56 19 8 8 8 8 8 8 8 8 8 7 7 6 6 6 6 6 6 y = 56 56 19 8 8 8 8 8 8 8 8 8 7 7 6 6 6 6 6 6 6 y = 56 56 19 8 8 8 8 8 8 8 8 8 7 7 6 6 6 6 6 6 6 6 y = 56 56 19 8 8 8 8 8 8 8 8 8 7 7 6 6 6 6 6 6 6 6 6 y = 56 56 19 8 8 8 8 8 8 8 8 8 7 7 6 6 6 6 6 6 6 6 6 6 y = 56 56 19 8 8 8 8 8 8 8 8 8 7 7 6 6 6 6 6 6 6 6 6 6 6 y = 56 56 19 8 8 8 8 8 8 8 8 8 7 7 6 6 6 6 6 6 6 6 6 6 6 6 y = 56 56 19 8 8 8 8 8 8 8 8 8 7 7 6 6 6 6 6 6 6 6 6 6 6 6 6 y = 56 56 19 8 8 8 8 8 8 8 8 8 7 7 6 6 6 6 6 6 6 6 6 6 6 6 6 6 y = 56 56 19 8 8 8 8 8 8 8 8 8 7 7 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 y = 56 56 19 8 8 8 8 8 8 8 8 8 7 7 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 y = Columns 1 through 30 56 56 19 8 8 8 8 8 8 8 8 8 7 7 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 Column 31 6 y = Columns 1 through 30 56 56 19 8 8 8 8 8 8 8 8 8 7 7 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 Columns 31 through 32 6 6 y = Columns 1 through 30 56 56 19 8 8 8 8 8 8 8 8 8 7 7 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 Columns 31 through 33 6 6 6 y = Columns 1 through 30 56 56 19 8 8 8 8 8 8 8 8 8 7 7 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 Columns 31 through 34 6 6 6 6 y = Columns 1 through 30 56 56 19 8 8 8 8 8 8 8 8 8 7 7 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 Columns 31 through 35 6 6 6 6 6 y = Columns 1 through 30 56 56 19 8 8 8 8 8 8 8 8 8 7 7 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 Columns 31 through 36 6 6 6 6 6 6 y = Columns 1 through 30 56 56 19 8 8 8 8 8 8 8 8 8 7 7 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 Columns 31 through 37 6 6 6 6 6 6 6 y = Columns 1 through 30 56 56 19 8 8 8 8 8 8 8 8 8 7 7 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 Columns 31 through 38 6 6 6 6 6 6 6 6 y = Columns 1 through 30 56 56 19 8 8 8 8 8 8 8 8 8 7 7 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 Columns 31 through 39 6 6 6 6 6 6 6 6 6 y = Columns 1 through 30 56 56 19 8 8 8 8 8 8 8 8 8 7 7 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 Columns 31 through 40 6 6 6 6 6 6 6 6 6 6 y = Columns 1 through 30 56 56 19 8 8 8 8 8 8 8 8 8 7 7 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 Columns 31 through 41 6 6 6 6 6 6 6 6 6 6 6 y = 56 y = 56 56 y = 56 56 19 y = 56 56 19 8 y = 56 56 19 8 8 y = 56 56 19 8 8 8 y = 56 56 19 8 8 8 8 y = 56 56 19 8 8 8 8 8 y = 56 56 19 8 8 8 8 8 8 y = 56 56 19 8 8 8 8 8 8 8 y = 56 56 19 8 8 8 8 8 8 8 8 y = 56 56 19 8 8 8 8 8 8 8 8 8 y = 56 56 19 8 8 8 8 8 8 8 8 8 7 y = 56 56 19 8 8 8 8 8 8 8 8 8 7 7 y = 56 56 19 8 8 8 8 8 8 8 8 8 7 7 6 y = 56 56 19 8 8 8 8 8 8 8 8 8 7 7 6 6 y = 56 56 19 8 8 8 8 8 8 8 8 8 7 7 6 6 6 y = 56 56 19 8 8 8 8 8 8 8 8 8 7 7 6 6 6 6 y = 56 56 19 8 8 8 8 8 8 8 8 8 7 7 6 6 6 6 6 y = 56 56 19 8 8 8 8 8 8 8 8 8 7 7 6 6 6 6 6 6 y = 56 56 19 8 8 8 8 8 8 8 8 8 7 7 6 6 6 6 6 6 6 y = 56 56 19 8 8 8 8 8 8 8 8 8 7 7 6 6 6 6 6 6 6 6 y = 56 56 19 8 8 8 8 8 8 8 8 8 7 7 6 6 6 6 6 6 6 6 6 y = 56 56 19 8 8 8 8 8 8 8 8 8 7 7 6 6 6 6 6 6 6 6 6 6 y = 56 56 19 8 8 8 8 8 8 8 8 8 7 7 6 6 6 6 6 6 6 6 6 6 6 y = 56 56 19 8 8 8 8 8 8 8 8 8 7 7 6 6 6 6 6 6 6 6 6 6 6 6 y = 56 56 19 8 8 8 8 8 8 8 8 8 7 7 6 6 6 6 6 6 6 6 6 6 6 6 6 y = 56 56 19 8 8 8 8 8 8 8 8 8 7 7 6 6 6 6 6 6 6 6 6 6 6 6 6 6 y = 56 56 19 8 8 8 8 8 8 8 8 8 7 7 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 y = 56 56 19 8 8 8 8 8 8 8 8 8 7 7 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 y = Columns 1 through 30 56 56 19 8 8 8 8 8 8 8 8 8 7 7 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 Column 31 6 y = Columns 1 through 30 56 56 19 8 8 8 8 8 8 8 8 8 7 7 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 Columns 31 through 32 6 6 y = Columns 1 through 30 56 56 19 8 8 8 8 8 8 8 8 8 7 7 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 Columns 31 through 33 6 6 6 y = Columns 1 through 30 56 56 19 8 8 8 8 8 8 8 8 8 7 7 6 6 6 6 6 6 6 6 6 6 6 6 ...

Assertion failed.

5   Fail
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 y = 92 92 y = 92 92 4 y = 92 92 4 4 y = 92 92 4 4 4 y = 92 92 4 4 4 4 y = 92 92 4 4 4 4 4 y = 92 92 4 4 4 4 4 4 y = 92 92 4 4 4 4 4 4 4 y = 92 92 4 4 4 4 4 4 4 4

Assertion failed.

6   Fail
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')))

Output argument "y" (and maybe others) not assigned during call to "cumin". Error in Test6 (line 2) assert(isequal(cumin(x),cummin(x)))