Cody

# Problem 980. Unique values without using UNIQUE function

Solution 2800588

Submitted on 6 Aug 2020 by Cassidy Fialkiewicz
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 i = 1:length(x) ele = x(i) if (any(y==ele)) == false y = [y ele] end end end %This code written by profile_id 18618081 ' ele = 9 y = 9 ele = 2 y = 9 2 ele = 9 ele = 5 y = 9 2 5

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

ele = 42 y = 42 ele = 1 y = 42 1 ele = 1 ele = 1 ele = 42 ele = 17 y = 42 1 17 ele = 17

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

ele = 0.5228 y = 0.5228 ele = 0.4709 y = 0.5228 0.4709 ele = 0.5757 y = 0.5228 0.4709 0.5757 ele = 0.0668 y = 0.5228 0.4709 0.5757 0.0668 ele = 0.7532 y = 0.5228 0.4709 0.5757 0.0668 0.7532 ele = 0.1769 y = 0.5228 0.4709 0.5757 0.0668 0.7532 0.1769 ele = 0.8265 y = 0.5228 0.4709 0.5757 0.0668 0.7532 0.1769 0.8265 ele = 0.6088 y = 0.5228 0.4709 0.5757 0.0668 0.7532 0.1769 0.8265 0.6088 ele = 0.9469 y = 0.5228 0.4709 0.5757 0.0668 0.7532 0.1769 0.8265 0.6088 0.9469 ele = 0.2245 y = 0.5228 0.4709 0.5757 0.0668 0.7532 0.1769 0.8265 0.6088 0.9469 0.2245 ele = 0.2198 y = 0.5228 0.4709 0.5757 0.0668 0.7532 0.1769 0.8265 0.6088 0.9469 0.2245 0.2198 ele = 0.8919 y = 0.5228 0.4709 0.5757 0.0668 0.7532 0.1769 0.8265 0.6088 0.9469 0.2245 0.2198 0.8919 ele = 0.3454 y = 0.5228 0.4709 0.5757 0.0668 0.7532 0.1769 0.8265 0.6088 0.9469 0.2245 0.2198 0.8919 0.3454 ele = 0.2816 y = 0.5228 0.4709 0.5757 0.0668 0.7532 0.1769 0.8265 0.6088 0.9469 0.2245 0.2198 0.8919 0.3454 0.2816 ele = 0.6792 y = 0.5228 0.4709 0.5757 0.0668 0.7532 0.1769 0.8265 0.6088 0.9469 0.2245 0.2198 0.8919 0.3454 0.2816 0.6792 ele = 0.9370 y = 0.5228 0.4709 0.5757 0.0668 0.7532 0.1769 0.8265 0.6088 0.9469 0.2245 0.2198 0.8919 0.3454 0.2816 0.6792 0.9370 ele = 0.2819 y = 0.5228 0.4709 0.5757 0.0668 0.7532 0.1769 0.8265 0.6088 0.9469 0.2245 0.2198 0.8919 0.3454 0.2816 0.6792 0.9370 0.2819 ele = 0.4900 y = 0.5228 0.4709 0.5757 0.0668 0.7532 0.1769 0.8265 0.6088 0.9469 0.2245 0.2198 0.8919 0.3454 0.2816 0.6792 0.9370 0.2819 0.4900 ele = 0.2981 y = Columns 1 through 18 0.5228 0.4709 0.5757 0.0668 0.7532 0.1769 0.8265 0.6088 0.9469 0.2245 0.2198 0.8919 0.3454 0.2816 0.6792 0.9370 0.2819 0.4900 Column 19 0.2981 ele = 0.8014 y = Columns 1 through 18 0.5228 0.4709 0.5757 0.0668 0.7532 0.1769 0.8265 0.6088 0.9469 0.2245 0.2198 0.8919 0.3454 0.2816 0.6792 0.9370 0.2819 0.4900 Columns 19 through 20 0.2981 0.8014 ele = 0.1500 y = Columns 1 through 18 0.5228 0.4709 0.5757 0.0668 0.7532 0.1769 0.8265 0.6088 0.9469 0.2245 0.2198 0.8919 0.3454 0.2816 0.6792 0.9370 0.2819 0.4900 Columns 19 through 21 0.2981 0.8014 0.1500 ele = 0.9156 y = Columns 1 through 18 0.5228 0.4709 0.5757 0.0668 0.7532 0.1769 0.8265 0.6088 0.9469 0.2245 0.2198 0.8919 0.3454 0.2816 0.6792 0.9370 0.2819 0.4900 Columns 19 through 22 0.2981 0.8014 0.1500 0.9156 ele = 0.0453 y = Columns 1 through 18 0.5228 0.4709 0.5757 0.0668 0.7532 0.1769 0.8265 0.6088 0.9469 0.2245 0.2198 0.8919 0.3454 0.2816 0.6792 0.9370 0.2819 0.4900 Columns 19 through 23 0.2981 0.8014 0.1500 0.9156 0.0453 ele = 0.4126 y = Columns 1 through 18 0.5228 0.4709 0.5757 0.0668 0.7532 0.1769 0.8265 0.6088 0.9469 0.2245 0.2198 0.8919 0.3454 0.2816 0.6792 0.9370 0.2819 0.4900 Columns 19 through 24 0.2981 0.8014 0.1500 0.9156 0.0453 0.4126 ele = 0.6333 y = Columns 1 through 18 0.5228 0.4709 0.5757 0.0668 0.7532 0.1769 0.8265 0.6088 0.9469 0.2245 0.2198 0.8919 0.3454 0.2816 0.6792 0.9370 0.2819 0.4900 Columns 19 through 25 0.2981 0.8014 0.1500 0.9156 0.0453 0.4126 0.6333