Cody

Solution 2044528

Submitted on 3 Dec 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
filetext = fileread('your_fcn_name.m') assert(isempty(strfind(filetext, 'unique'))) assert(isempty(strfind(filetext, 'stable'))) A = [9 2 9 5]; assert(isequal(your_fcn_name(A),unique(A,'stable')))

filetext = 'function y = your_fcn_name(x) %function y = unique(x) a =length(x) k=1; z=x; for i=1:a b=find(z==x(i)) if numel(b)==1 y(k)=z(b) k=k+1; z(b)=[] elseif numel(b)>1 y(k)=z(b(1)) k=k+1; z(b)=[] end end end %This code written by profile_id 16549154 '

Assertion failed.

2   Pass
x = [42 1 1 1 42 17 17]; assert(isequal(your_fcn_name(x),unique(x,'stable')))

a = 7 b = 1 5 y = 42 z = 1 1 1 17 17 b = 1 2 3 y = 42 1 z = 17 17 b = 1×0 empty double row vector b = 1×0 empty double row vector b = 1×0 empty double row vector b = 1 2 y = 42 1 17 z = 1×0 empty double row vector b = 1×0 empty double row vector

3   Pass
x = rand(1,25); assert(isequal(your_fcn_name(x),unique(x,'stable')))

a = 25 b = 1 y = 0.2116 z = Columns 1 through 18 0.6456 0.4286 0.5102 0.4303 0.1170 0.2617 0.7703 0.6215 0.5034 0.9248 0.9473 0.8013 0.3999 0.9660 0.0571 0.8486 0.7477 0.1066 Columns 19 through 24 0.9103 0.0832 0.0078 0.4602 0.6489 0.1813 b = 1 y = 0.2116 0.6456 z = Columns 1 through 18 0.4286 0.5102 0.4303 0.1170 0.2617 0.7703 0.6215 0.5034 0.9248 0.9473 0.8013 0.3999 0.9660 0.0571 0.8486 0.7477 0.1066 0.9103 Columns 19 through 23 0.0832 0.0078 0.4602 0.6489 0.1813 b = 1 y = 0.2116 0.6456 0.4286 z = Columns 1 through 18 0.5102 0.4303 0.1170 0.2617 0.7703 0.6215 0.5034 0.9248 0.9473 0.8013 0.3999 0.9660 0.0571 0.8486 0.7477 0.1066 0.9103 0.0832 Columns 19 through 22 0.0078 0.4602 0.6489 0.1813 b = 1 y = 0.2116 0.6456 0.4286 0.5102 z = Columns 1 through 18 0.4303 0.1170 0.2617 0.7703 0.6215 0.5034 0.9248 0.9473 0.8013 0.3999 0.9660 0.0571 0.8486 0.7477 0.1066 0.9103 0.0832 0.0078 Columns 19 through 21 0.4602 0.6489 0.1813 b = 1 y = 0.2116 0.6456 0.4286 0.5102 0.4303 z = Columns 1 through 18 0.1170 0.2617 0.7703 0.6215 0.5034 0.9248 0.9473 0.8013 0.3999 0.9660 0.0571 0.8486 0.7477 0.1066 0.9103 0.0832 0.0078 0.4602 Columns 19 through 20 0.6489 0.1813 b = 1 y = 0.2116 0.6456 0.4286 0.5102 0.4303 0.1170 z = Columns 1 through 18 0.2617 0.7703 0.6215 0.5034 0.9248 0.9473 0.8013 0.3999 0.9660 0.0571 0.8486 0.7477 0.1066 0.9103 0.0832 0.0078 0.4602 0.6489 Column 19 0.1813 b = 1 y = 0.2116 0.6456 0.4286 0.5102 0.4303 0.1170 0.2617 z = 0.7703 0.6215 0.5034 0.9248 0.9473 0.8013 0.3999 0.9660 0.0571 0.8486 0.7477 0.1066 0.9103 0.0832 0.0078 0.4602 0.6489 0.1813 b = 1 y = 0.2116 0.6456 0.4286 0.5102 0.4303 0.1170 0.2617 0.7703 z = 0.6215 0.5034 0.9248 0.9473 0.8013 0.3999 0.9660 0.0571 0.8486 0.7477 0.1066 0.9103 0.0832 0.0078 0.4602 0.6489 0.1813 b = 1 y = 0.2116 0.6456 0.4286 0.5102 0.4303 0.1170 0.2617 0.7703 0.6215 z = 0.5034 0.9248 0.9473 0.8013 0.3999 0.9660 0.0571 0.8486 0.7477 0.1066 0.9103 0.0832 0.0078 0.4602 0.6489 0.1813 b = 1 y = 0.2116 0.6456 0.4286 0.5102 0.4303 0.1170 0.2617 0.7703 0.6215 0.5034 z = 0.9248 0.9473 0.8013 0.3999 0.9660 0.0571 0.8486 0.7477 0.1066 0.9103 0.0832 0.0078 0.4602 0.6489 0.1813 b = 1 y = 0.2116 0.6456 0.4286 0.5102 0.4303 0.1170 0.2617 0.7703 0.6215 0.5034 0.9248 z = 0.9473 0.8013 0.3999 0.9660 0.0571 0.8486 0.7477 0.1066 0.9103 0.0832 0.0078 0.4602 0.6489 0.1813 b = 1 y = 0.2116 0.6456 0.4286 0.5102 0.4303 0.1170 0.2617 0.7703 0.6215 0.5034 0.9248 0.9473 z = 0.8013 0.3999 0.9660 0.0571 0.8486 0.7477 0.1066 0.9103 0.0832 0.0078 0.4602 0.6489 0.1813 b = 1 y = 0.2116 0.6456 0.4286 0.5102 0.4303 0.1170 0.2617 0.7703 0.6215 0.5034 0.9248 0.9473 0.8013 z = 0.3999 0.9660 0.0571 0.8486 0.7477 0.1066 0.9103 0.0832 0.0078 0.4602 0.6489 0.1813 b = 1 y = 0.2116 0.6456 0.4286 0.5102 0.4303 0.1170 0.2617 0.7703 0.6215 0.5034 0.9248 0.9473 0.8013 0.3999 z = 0.9660 0.0571 0.8486 0.7477 0.1066 0.9103 0.0832 0.0078 0.4602 0.6489 0.1813 b = 1 y = 0.2116 0.6456 0.4286 0.5102 0.4303 0.1170 0.2617 0.7703 0.6215 0.5034 0.9248 0.9473 0.8013 0.3999 0.9660 z = 0.0571 0.8486 0.7477 0.1066 0.9103 0.0832 0.0078 0.4602 0.6489 0.1813 b = 1 y = 0.2116 0.6456 0.4286 0.5102 0.4303 0.1170 0.2617 0.7703 0.6215 0.5034 0.9248 0.9473 0.8013 0.3999 0.9660 0.0571 z = 0.8486 0.7477 0.1066 0.9103 0.0832 0.0078 0.4602 0.6489 0.1813 b = 1 y = 0.2116 0.6456 0.4286 0.5102 0.4303 0.1170 0.2617 0.7703 0.6215 0.5034 0.9248 0.9473 0.8013 0.3999 0.9660 0.0571 0.8486 z = 0.7477 0.1066 0.9103 0.0832 0.0078 0.4602 0.6489 0.1813 b = 1 y = 0.2116 0.6456 0.4286 0.5102 0.4303 0.1170 0.2617 0.7703 0.6215 0.5034 0.9248 0.9473 0.8013 0.3999 0.9660 0.0571 0.8486 0.7477 z = 0.1066 0.9103 0.0832 0.0078 0.4602 0.6489 0.1813 b = 1 y = Columns 1 through 18 0.2116 0.6456 0.4286 0.5102 0.4303 0.1170 0.2617 0.7703 0.6215 0.5034 0.9248 0.9473 0.8013 0.3999 0.9660 0.0571 0.8486 0.7477 Column 19 0.1066 z = 0.9103 0.0832 0.0078 0.4602 0.6489 0.1813 b = 1 y = Columns 1 through 18 0.2116 0.6456 0.4286 0.5102 0.4303 0.1170 0.2617 0.7703 0.6215 0.5034 0.9248 0.9473 0.8013 0.3999 0.9660 0.0571 0.8486 0.7477 Columns 19 through 20 0.1066 0.9103 z = 0.0832 0.0078 0.4602 0.6489 0.1813 b = 1 y = Columns 1 through 18 0.2116 0.6456 0.4286 0.5102 0.4303 0.1170 0.2617 0.7703 0.6215 0.5034 0.9248 0.9473 0.8013 0.3999 0.9660 0.0571 0.8486 0.7477 Columns 19 through 21 0.1066 0.9103 0.0832 z = 0.0078 0.4602 0.6489 0.1813 b = 1 y = Columns 1 through 18 0.2116 0.6456 0.4286 0.5102 0.4303 0.1170 0.2617 0.7703 0.6215 0.5034 0.9248 0.9473 0.8013 0.3999 0.9660 0.0571 0.8486 0.7477 Columns 19 through 22 0.1066 0.9103 0.0832 0.0078 z = 0.4602 0.6489 0.1813 b = 1 y = Columns 1 through 18 0.2116 0.6456 0.4286 0.5102 0.4303 0.1170 0.2617 0.7703 0.6215 0.5034 0.9248 0.9473 0.8013 0.3999 0.9660 0.0571 0.8486 0.7477 Columns 19 through 23 0.1066 0.9103 0.0832 0.0078 0.4602 z = 0.6489 0.1813 b = 1 y = Columns 1 through 18 0.2116 0.6456 0.4286 0.5102 0.4303 0.1170 0.2617 0.7703 0.6215 0.5034 0.9248 0.9473 0.8013 0.3999 0.9660 0.0571 0.8486 0.7477 Columns 19 through 24 0.1066 0.9103 0.0832 0.0078 0.4602 0.6489 z = 0.1813 b = 1 y = Columns 1 through 18 0.2116 0.6456 0.4286 0.5102 0.4303 0.1170 0.2617 0.7703 0.6215 0.5034 0.9248 0.9473 0.8013 0.3999 0.9660 0.0571 0.8486 0.7477 Columns 19 through 25 0.1066 0.9103 0.0832 0.0078 0.4602 0.6489 0.1813 z = 1×0 empty double row vector