Cody

Solution 1981451

Submitted on 18 Oct 2019
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   Fail
x = (1:20)'; fh = @(xi) mod(xi, 2) == 0; y_correct = (2:2:20)'; assert(isequal(filterfun(fh, x), y_correct));

y = 20×1 logical array 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1

Assertion failed.

2   Fail
x = 'Aa is lava.'; fh = @(c) lower(c) == 'a'; y_correct = 'Aaaa'; assert(isequal(filterfun(fh, x), y_correct));

y = 1×11 logical array 1 1 0 0 0 0 0 1 0 1 0

Assertion failed.

3   Fail
x = {[]; 1; [1;2]; [2 3 4]; ones(1,1,3)}; fh = @isrow; y_correct = {1; [2 3 4]}; assert(isequal(filterfun(fh, x), y_correct));

y = logical 0

Assertion failed.

Suggested Problems

More from this Author1