Cody

# Problem 53. Duplicates

Solution 1212486

Submitted on 14 Jun 2017 by Ayanle Aden
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)))

Bin = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Bin = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Bin = 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 Bin = 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 Bin = 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 Bin = 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 Bin = 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 Bin = 0 0 1 1 0 0 0 0 1 0 0 0 0 0 0 0 Bin = 0 0 1 1 0 0 0 0 1 0 0 0 0 0 0 0 Bin = 0 0 1 1 0 0 0 0 1 0 0 1 0 0 0 0 Bin = 0 0 1 1 0 0 0 0 1 0 0 1 1 0 0 0 Bin = 0 0 1 1 0 0 0 0 1 0 0 1 1 0 0 0 Bin = 0 0 1 1 0 0 0 0 1 0 0 1 1 0 1 0 n = 1 dups = cell 'aa' n = 2 dups = 1×2 cell array 'aa' 'aa' n = 3 dups = 1×3 cell array 'aa' 'aa' 'aa' n = 4 dups = 1×4 cell array 'aa' 'aa' 'aa' 'aa' n = 5 dups = 1×5 cell array 'aa' 'aa' 'aa' 'aa' 'aa' n = 6 dups = 1×6 cell array 'aa' 'aa' 'aa' 'aa' 'aa' 'aa' n = 7

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

Bin = 0 0 0 0 0 0 0 0 0 Bin = 0 0 0 0 0 0 0 0 0 Bin = 0 0 0 0 0 0 0 0 0 Bin = 0 0 0 0 0 0 0 0 0 Bin = 0 0 0 0 0 0 0 0 0 Bin = 0 0 0 0 0 0 0 0 0 Bin = 0 0 0 0 0 0 0 0 0 n = 1 dups = 0×0 empty cell array

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

Bin = 0 0 0 0 0 0 0 0 0 Bin = 0 1 0 0 0 0 0 0 0 Bin = 0 1 1 0 0 0 0 0 0 Bin = 0 1 1 1 0 0 0 0 0 Bin = 0 1 1 1 0 1 0 0 0 Bin = 0 1 1 1 0 1 1 0 0 Bin = 0 1 1 1 0 1 1 1 0 n = 1 dups = cell 'zzz' n = 2 dups = 1×2 cell array 'zzz' 'zzz' n = 3 dups = 1×3 cell array 'zzz' 'zzz' 'zzz' n = 4 dups = 1×4 cell array 'zzz' 'zzz' 'zzz' 'zzz' n = 5 dups = 1×5 cell array 'zzz' 'zzz' 'zzz' 'zzz' 'zzz' n = 6 dups = 1×6 cell array 'zzz' 'zzz' 'zzz' 'zzz' 'zzz' 'zzz' n = 7

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

Bin = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Bin = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Bin = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Bin = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Bin = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Bin = 0 0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 'b' 'c' 'b' n = 4 dups = 1×4 cell array 'b' 'c' 'b' 'c' n = 5

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

Bin = [] n = 1 dups = 0×0 empty cell array