Cody

# Problem 980. Unique values without using UNIQUE function

Solution 1603647

Submitted on 8 Aug 2018 by Srishti Saha
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) if ismember(x(i),y)~=1 append=x(i) else append=[] end y=[y append] end end %This code written by profile_id 4892831 ' y = [] append = 9 y = 9 append = 2 y = 9 2 append = [] y = 9 2 append = 5 y = 9 2 5

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

y = [] append = 42 y = 42 append = 1 y = 42 1 append = [] y = 42 1 append = [] y = 42 1 append = [] y = 42 1 append = 17 y = 42 1 17 append = [] y = 42 1 17

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

y = [] append = 0.6317 y = 0.6317 append = 0.4052 y = 0.6317 0.4052 append = 0.6550 y = 0.6317 0.4052 0.6550 append = 0.1776 y = 0.6317 0.4052 0.6550 0.1776 append = 0.0447 y = 0.6317 0.4052 0.6550 0.1776 0.0447 append = 0.7895 y = 0.6317 0.4052 0.6550 0.1776 0.0447 0.7895 append = 0.3514 y = 0.6317 0.4052 0.6550 0.1776 0.0447 0.7895 0.3514 append = 0.1934 y = 0.6317 0.4052 0.6550 0.1776 0.0447 0.7895 0.3514 0.1934 append = 0.3921 y = 0.6317 0.4052 0.6550 0.1776 0.0447 0.7895 0.3514 0.1934 0.3921 append = 0.4758 y = 0.6317 0.4052 0.6550 0.1776 0.0447 0.7895 0.3514 0.1934 0.3921 0.4758 append = 0.4006 y = 0.6317 0.4052 0.6550 0.1776 0.0447 0.7895 0.3514 0.1934 0.3921 0.4758 0.4006 append = 0.8995 y = 0.6317 0.4052 0.6550 0.1776 0.0447 0.7895 0.3514 0.1934 0.3921 0.4758 0.4006 0.8995 append = 0.4546 y = 0.6317 0.4052 0.6550 0.1776 0.0447 0.7895 0.3514 0.1934 0.3921 0.4758 0.4006 0.8995 0.4546 append = 0.5764 y = 0.6317 0.4052 0.6550 0.1776 0.0447 0.7895 0.3514 0.1934 0.3921 0.4758 0.4006 0.8995 0.4546 0.5764 append = 0.7029 y = 0.6317 0.4052 0.6550 0.1776 0.0447 0.7895 0.3514 0.1934 0.3921 0.4758 0.4006 0.8995 0.4546 0.5764 0.7029 append = 0.0664 y = 0.6317 0.4052 0.6550 0.1776 0.0447 0.7895 0.3514 0.1934 0.3921 0.4758 0.4006 0.8995 0.4546 0.5764 0.7029 0.0664 append = 0.4659 y = 0.6317 0.4052 0.6550 0.1776 0.0447 0.7895 0.3514 0.1934 0.3921 0.4758 0.4006 0.8995 0.4546 0.5764 0.7029 0.0664 0.4659 append = 0.8800 y = Columns 1 through 17 0.6317 0.4052 0.6550 0.1776 0.0447 0.7895 0.3514 0.1934 0.3921 0.4758 0.4006 0.8995 0.4546 0.5764 0.7029 0.0664 0.4659 Column 18 0.8800 append = 0.2273 y = Columns 1 through 17 0.6317 0.4052 0.6550 0.1776 0.0447 0.7895 0.3514 0.1934 0.3921 0.4758 0.4006 0.8995 0.4546 0.5764 0.7029 0.0664 0.4659 Columns 18 through 19 0.8800 0.2273 append = 0.2849 y = Columns 1 through 17 0.6317 0.4052 0.6550 0.1776 0.0447 0.7895 0.3514 0.1934 0.3921 0.4758 0.4006 0.8995 0.4546 0.5764 0.7029 0.0664 0.4659 Columns 18 through 20 0.8800 0.2273 0.2849 append = 0.5592 y = Columns 1 through 17 0.6317 0.4052 0.6550 0.1776 0.0447 0.7895 0.3514 0.1934 0.3921 0.4758 0.4006 0.8995 0.4546 0.5764 0.7029 0.0664 0.4659 Columns 18 through 21 0.8800 0.2273 0.2849 0.5592 append = 0.3233 y = Columns 1 through 17 0.6317 0.4052 0.6550 0.1776 0.0447 0.7895 0.3514 0.1934 0.3921 0.4758 0.4006 0.8995 0.4546 0.5764 0.7029 0.0664 0.4659 Columns 18 through 22 0.8800 0.2273 0.2849 0.5592 0.3233 append = 0.3739 y = Columns 1 through 17 0.6317 0.4052 0.6550 0.1776 0.0447 0.7895 0.3514 0.1934 0.3921 0.4758 0.4006 0.8995 0.4546 0.5764 0.7029 0.0664 0.4659 Columns 18 through 23 0.8800 0.2273 0.2849 0.5592 0.3233 0.3739 append = 0.1571 y = Columns 1 through 17 0.6317 0.4052 0.6550 0.1776 0.0447 0.7895 0.3514 0.1934 0.3921 0.4758 0.4006 0.8995 0.4546 0.5764 0.7029 0.0664 0.4659 Columns 18 through 24 0.8800 0.2273 0.2849 0.5592 0.3233 0.3739 0.1571 append = 0.9136 y = Columns 1 through 17 0.6317 0.4052 0.6550 0.1776 0.0447 0.7895 0.3514 0.1934 0.3921 0.4758 0.4006 0.8995 0.4546 0.5764 0.7029 0.0664 0.4659 Columns 18 through 25 0.8800 0.2273 0.2849 0.5592 0.3233 0.3739 0.1571 0.9136