Cody

# Problem 980. Unique values without using UNIQUE function

Solution 2884499

Submitted on 27 Aug 2020 by Pauli Huusari
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(1); for index = 2:1:numel(x) if all(y~=x(index)) y = [y x(index)] end end end %This code written by profile_id 5596781 ' 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 1 y = 42 1 17

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

y = 0.1555 0.9862 y = 0.1555 0.9862 0.4625 y = 0.1555 0.9862 0.4625 0.3119 y = 0.1555 0.9862 0.4625 0.3119 0.6763 y = 0.1555 0.9862 0.4625 0.3119 0.6763 0.2778 y = 0.1555 0.9862 0.4625 0.3119 0.6763 0.2778 0.0084 y = 0.1555 0.9862 0.4625 0.3119 0.6763 0.2778 0.0084 0.3940 y = 0.1555 0.9862 0.4625 0.3119 0.6763 0.2778 0.0084 0.3940 0.5221 y = 0.1555 0.9862 0.4625 0.3119 0.6763 0.2778 0.0084 0.3940 0.5221 0.3816 y = 0.1555 0.9862 0.4625 0.3119 0.6763 0.2778 0.0084 0.3940 0.5221 0.3816 0.4418 y = 0.1555 0.9862 0.4625 0.3119 0.6763 0.2778 0.0084 0.3940 0.5221 0.3816 0.4418 0.7510 y = 0.1555 0.9862 0.4625 0.3119 0.6763 0.2778 0.0084 0.3940 0.5221 0.3816 0.4418 0.7510 0.8955 y = 0.1555 0.9862 0.4625 0.3119 0.6763 0.2778 0.0084 0.3940 0.5221 0.3816 0.4418 0.7510 0.8955 0.7193 y = 0.1555 0.9862 0.4625 0.3119 0.6763 0.2778 0.0084 0.3940 0.5221 0.3816 0.4418 0.7510 0.8955 0.7193 0.4355 y = 0.1555 0.9862 0.4625 0.3119 0.6763 0.2778 0.0084 0.3940 0.5221 0.3816 0.4418 0.7510 0.8955 0.7193 0.4355 0.9433 y = 0.1555 0.9862 0.4625 0.3119 0.6763 0.2778 0.0084 0.3940 0.5221 0.3816 0.4418 0.7510 0.8955 0.7193 0.4355 0.9433 0.8467 y = 0.1555 0.9862 0.4625 0.3119 0.6763 0.2778 0.0084 0.3940 0.5221 0.3816 0.4418 0.7510 0.8955 0.7193 0.4355 0.9433 0.8467 0.0756 y = Columns 1 through 18 0.1555 0.9862 0.4625 0.3119 0.6763 0.2778 0.0084 0.3940 0.5221 0.3816 0.4418 0.7510 0.8955 0.7193 0.4355 0.9433 0.8467 0.0756 Column 19 0.9852 y = Columns 1 through 18 0.1555 0.9862 0.4625 0.3119 0.6763 0.2778 0.0084 0.3940 0.5221 0.3816 0.4418 0.7510 0.8955 0.7193 0.4355 0.9433 0.8467 0.0756 Columns 19 through 20 0.9852 0.7009 y = Columns 1 through 18 0.1555 0.9862 0.4625 0.3119 0.6763 0.2778 0.0084 0.3940 0.5221 0.3816 0.4418 0.7510 0.8955 0.7193 0.4355 0.9433 0.8467 0.0756 Columns 19 through 21 0.9852 0.7009 0.2015 y = Columns 1 through 18 0.1555 0.9862 0.4625 0.3119 0.6763 0.2778 0.0084 0.3940 0.5221 0.3816 0.4418 0.7510 0.8955 0.7193 0.4355 0.9433 0.8467 0.0756 Columns 19 through 22 0.9852 0.7009 0.2015 0.5109 y = Columns 1 through 18 0.1555 0.9862 0.4625 0.3119 0.6763 0.2778 0.0084 0.3940 0.5221 0.3816 0.4418 0.7510 0.8955 0.7193 0.4355 0.9433 0.8467 0.0756 Columns 19 through 23 0.9852 0.7009 0.2015 0.5109 0.4656 y = Columns 1 through 18 0.1555 0.9862 0.4625 0.3119 0.6763 0.2778 0.0084 0.3940 0.5221 0.3816 0.4418 0.7510 0.8955 0.7193 0.4355 0.9433 0.8467 0.0756 Columns 19 through 24 0.9852 0.7009 0.2015 0.5109 0.4656 0.4605 y = Columns 1 through 18 0.1555 0.9862 0.4625 0.3119 0.6763 0.2778 0.0084 0.3940 0.5221 0.3816 0.4418 0.7510 0.8955 0.7193 0.4355 0.9433 0.8467 0.0756 Columns 19 through 25 0.9852 0.7009 0.2015 0.5109 0.4656 0.4605 0.2380

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!