Cody

# Problem 980. Unique values without using UNIQUE function

Solution 2026363

Submitted on 18 Nov 2019 by Doan Quang Manh
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 = []; for k=1:length(x) if ismember(x(k),y)==0 y=[y x(k)] end end end %This code written by profile_id 16040633 ' y = 9 y = 9 2 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 y = 42 1 y = 42 1 17

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

y = 0.9283 y = 0.9283 0.9997 y = 0.9283 0.9997 0.3344 y = 0.9283 0.9997 0.3344 0.0010 y = 0.9283 0.9997 0.3344 0.0010 0.5127 y = 0.9283 0.9997 0.3344 0.0010 0.5127 0.8001 y = 0.9283 0.9997 0.3344 0.0010 0.5127 0.8001 0.4090 y = 0.9283 0.9997 0.3344 0.0010 0.5127 0.8001 0.4090 0.8808 y = 0.9283 0.9997 0.3344 0.0010 0.5127 0.8001 0.4090 0.8808 0.8947 y = 0.9283 0.9997 0.3344 0.0010 0.5127 0.8001 0.4090 0.8808 0.8947 0.1061 y = 0.9283 0.9997 0.3344 0.0010 0.5127 0.8001 0.4090 0.8808 0.8947 0.1061 0.7156 y = 0.9283 0.9997 0.3344 0.0010 0.5127 0.8001 0.4090 0.8808 0.8947 0.1061 0.7156 0.4665 y = 0.9283 0.9997 0.3344 0.0010 0.5127 0.8001 0.4090 0.8808 0.8947 0.1061 0.7156 0.4665 0.1026 y = 0.9283 0.9997 0.3344 0.0010 0.5127 0.8001 0.4090 0.8808 0.8947 0.1061 0.7156 0.4665 0.1026 0.1466 y = 0.9283 0.9997 0.3344 0.0010 0.5127 0.8001 0.4090 0.8808 0.8947 0.1061 0.7156 0.4665 0.1026 0.1466 0.0932 y = 0.9283 0.9997 0.3344 0.0010 0.5127 0.8001 0.4090 0.8808 0.8947 0.1061 0.7156 0.4665 0.1026 0.1466 0.0932 0.1676 y = 0.9283 0.9997 0.3344 0.0010 0.5127 0.8001 0.4090 0.8808 0.8947 0.1061 0.7156 0.4665 0.1026 0.1466 0.0932 0.1676 0.8764 y = 0.9283 0.9997 0.3344 0.0010 0.5127 0.8001 0.4090 0.8808 0.8947 0.1061 0.7156 0.4665 0.1026 0.1466 0.0932 0.1676 0.8764 0.0731 y = Columns 1 through 18 0.9283 0.9997 0.3344 0.0010 0.5127 0.8001 0.4090 0.8808 0.8947 0.1061 0.7156 0.4665 0.1026 0.1466 0.0932 0.1676 0.8764 0.0731 Column 19 0.2694 y = Columns 1 through 18 0.9283 0.9997 0.3344 0.0010 0.5127 0.8001 0.4090 0.8808 0.8947 0.1061 0.7156 0.4665 0.1026 0.1466 0.0932 0.1676 0.8764 0.0731 Columns 19 through 20 0.2694 0.4896 y = Columns 1 through 18 0.9283 0.9997 0.3344 0.0010 0.5127 0.8001 0.4090 0.8808 0.8947 0.1061 0.7156 0.4665 0.1026 0.1466 0.0932 0.1676 0.8764 0.0731 Columns 19 through 21 0.2694 0.4896 0.8008 y = Columns 1 through 18 0.9283 0.9997 0.3344 0.0010 0.5127 0.8001 0.4090 0.8808 0.8947 0.1061 0.7156 0.4665 0.1026 0.1466 0.0932 0.1676 0.8764 0.0731 Columns 19 through 22 0.2694 0.4896 0.8008 0.2958 y = Columns 1 through 18 0.9283 0.9997 0.3344 0.0010 0.5127 0.8001 0.4090 0.8808 0.8947 0.1061 0.7156 0.4665 0.1026 0.1466 0.0932 0.1676 0.8764 0.0731 Columns 19 through 23 0.2694 0.4896 0.8008 0.2958 0.2790 y = Columns 1 through 18 0.9283 0.9997 0.3344 0.0010 0.5127 0.8001 0.4090 0.8808 0.8947 0.1061 0.7156 0.4665 0.1026 0.1466 0.0932 0.1676 0.8764 0.0731 Columns 19 through 24 0.2694 0.4896 0.8008 0.2958 0.2790 0.8891 y = Columns 1 through 18 0.9283 0.9997 0.3344 0.0010 0.5127 0.8001 0.4090 0.8808 0.8947 0.1061 0.7156 0.4665 0.1026 0.1466 0.0932 0.1676 0.8764 0.0731 Columns 19 through 25 0.2694 0.4896 0.8008 0.2958 0.2790 0.8891 0.2903