Cody

# Problem 53. Duplicates

Solution 1848514

Submitted on 13 Jun 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   Pass
strs = {'aa','bb','aa','aa'}; correct = {'aa'}; result = duplicates(strs); assert(isempty(setdiff(result,correct)) & isempty(setdiff(correct,result)))

a = 1×2 cell array {'aa'} {'bb'} b = 1×2 cell array {[3]} {[1]}

2   Pass
strs = {'10','11','12'}; correct = {}; result = duplicates(strs); assert(isempty(setdiff(result,correct)) & isempty(setdiff(correct,result)))

a = 1×3 cell array {'10'} {'11'} {'12'} b = 1×3 cell array {[1]} {[1]} {[1]}

3   Pass
strs = {'zzz','zzz','zzz'}; correct = {'zzz'}; result = duplicates(strs); assert(isempty(setdiff(result,correct)) & isempty(setdiff(correct,result)))

a = 1×1 cell array {'zzz'} b = 1×1 cell array {[3]}

4   Fail
strs = {'a','b','c','b','d','c'}; correct = {'b','c'}; result = duplicates(strs); assert(isempty(setdiff(result,correct)) & isempty(setdiff(correct,result)))

a = 1×4 cell array {'a'} {'b'} {'c'} {'d'} b = 1×4 cell array {[1]} {[2]} {[2]} {[1]}

Error using cell/setdiff>cellsetdiffR2012a (line 291) Input A of class cell and input B of class cell must be cell arrays of character vectors, unless one is a character vector. Error in cell/setdiff (line 83) [varargout{1:nlhs}] = cellsetdiffR2012a(varargin{:}); Error in Test4 (line 4) assert(isempty(setdiff(result,correct)) & isempty(setdiff(correct,result)))

5   Fail
strs = {}; correct = {}; result = duplicates(strs); assert(isempty(setdiff(result,correct)) & isempty(setdiff(correct,result)))

a = 0×1 empty cell array b = 0×1 empty cell array

Output argument "x" (and maybe others) not assigned during call to "duplicates". Error in Test5 (line 3) result = duplicates(strs);