Cody

Problem 44324. Rewrite setdiff to account for non-unique values

Solution 2863220

Submitted on 21 Aug 2020
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
a=[1 1 2 3 4 5 6 7 8]; b=[1 3 4 5 6 7]; y_correct=[1 2 8]; assert(isequal(new_setdiff(a,b),y_correct)) assert(isequal(new_setdiff(fliplr(a),b),y_correct)) assert(isequal(new_setdiff(a,fliplr(b)),y_correct))

Output argument "y" (and maybe others) not assigned during call to "new_setdiff". Error in Test1 (line 3) assert(isequal(new_setdiff(a,b),y_correct))

2   Fail
a=repmat([1:10],1,2); b=repmat([1:5],1,2); y_correct=[6 6 7 7 8 8 9 9 10 10]; assert(isequal(new_setdiff(a,b),y_correct))

Output argument "y" (and maybe others) not assigned during call to "new_setdiff". Error in Test2 (line 4) assert(isequal(new_setdiff(a,b),y_correct))

3   Fail
a=[randperm(10) 3 5 7]; b=randperm(6)+1; y_correct=[1 3 5 7 8 9 10]; assert(isequal(new_setdiff(a,b),y_correct))

Output argument "y" (and maybe others) not assigned during call to "new_setdiff". Error in Test3 (line 4) assert(isequal(new_setdiff(a,b),y_correct))

4   Fail
a=[-5:5 -4:4]; b=[-4:4]; y_correct=[-5:5] assert(isequal(new_setdiff(a,b),y_correct))

y_correct = -5 -4 -3 -2 -1 0 1 2 3 4 5

Output argument "y" (and maybe others) not assigned during call to "new_setdiff". Error in Test4 (line 4) assert(isequal(new_setdiff(a,b),y_correct))

5   Fail
a=[2 2 2 2 3 3 5 7]; b=[2 2 2 2 3 3 5]; y_correct=8; assert(isequal(new_setdiff(a,b),y_correct-1))

Output argument "y" (and maybe others) not assigned during call to "new_setdiff". Error in Test5 (line 4) assert(isequal(new_setdiff(a,b),y_correct-1))

6   Fail
a=[21 124 23 20 21 23 124]; b=[20 21 21 23 23]; y_correct=[124 124] assert(isequal(new_setdiff(a,b),y_correct))

y_correct = 124 124

Output argument "y" (and maybe others) not assigned during call to "new_setdiff". Error in Test6 (line 4) assert(isequal(new_setdiff(a,b),y_correct))