Cody

# Problem 42631. Cumulative minimum of an array

Solution 1945987

Submitted on 22 Sep 2019 by Augusto Mazzei
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')))

dir = 1×0 empty double row vector dir = 1×0 empty double row vector dir = 1×0 empty double row vector dir = 1×0 empty double row vector dir = 1×0 empty double row vector dir = 1×0 empty double row vector

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

dir = 1 dir = 1 dir = 1 dir = 1 dir = 2 dir = 1 dir = 1 rev = 1 dir = 1 dir = 2 rev = 1 dir = 1 rev = 1

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

dir = 2 dir = 2 dir = 1 dir = 2 dir = 2 dir = 2 dir = 1 rev = 1 dir = 2 dir = 2 rev = 1 dir = 2 rev = 1

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

dir = 1 dir = 1 dir = 1 dir = 1 dir = 2 dir = 1 dir = 1 rev = 1 dir = 1 dir = 2 rev = 1 dir = 1 rev = 1

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

dir = 1×0 empty double row vector dir = 1×0 empty double row vector dir = 1×0 empty double row vector dir = 1×0 empty double row vector dir = 1×0 empty double row vector dir = 1×0 empty double row vector