Cody

Problem 2456. remove single elements

Solution 1601485

Submitted on 5 Aug 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
vec = [2 2 1 2 3 4 1 2]; out = [2 2 1 2 1 2]; assert(isequal(removeSingle(vec),out))

2   Pass
vec = ones(1,10000); out = vec; assert(isequal(removeSingle(vec),out))

3   Pass
vec = []; out = []; assert(isequal(removeSingle(vec),out))

4   Fail
vec = [1 2 3 4 5]; out = []; assert(isequal(removeSingle(vec),out))

Assertion failed.

5   Pass
vec = [4 4 5 5 1 1 2 2]; out = vec; assert(isequal(removeSingle(vec),out))

6   Pass
vec = [4 1 4]; out = [4 4]; assert(isequal(removeSingle(vec),out))

7   Pass
s = evalc('type removeSingle'); if (~isempty(regexp(s,'for'))) | (~isempty(regexp(s,'while'))) | (~isempty(regexp(s,'assert'))) | (~isempty(regexp(s,'error'))) while(1) end end

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!