Cody

# Problem 42631. Cumulative minimum of an array

Solution 1498472

Submitted on 20 Apr 2018 by cokakola
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')))

2 1 1 1 2 1 1 2 2 2 2 2

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

1 1 1 1 2 1 1 2 2 2 1 2

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

2 1 1 1 2 1 1 2 2 2 2 2

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

1 1 1 1 2 1 1 2 2 2 1 2

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

1 1 1 1 2 1 1 2 2 2 1 2