Cody

Problem 980. Unique values without using UNIQUE function

Solution 2645669

Submitted on 2 Jul 2020 by Rachelle Lee
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
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) y=x; out=zeros(1,length(x)); for i=2:length(x) idx=1; while idx<i if y(i)==x(idx) out(i)=1; end idx=idx+1; end end y=y(~out) end %This code written by profile_id 18692599 ' y = 9 2 5

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

y = 42 1 17

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

y = Columns 1 through 18 0.8440 0.9200 0.2358 0.2493 0.3260 0.6660 0.6157 0.1663 0.2241 0.6323 0.3322 0.4154 0.5941 0.6955 0.4348 0.6964 0.6900 0.4239 Columns 19 through 25 0.0249 0.5193 0.3000 0.9359 0.7720 0.9786 0.9890