Cody

Problem 980. Unique values without using UNIQUE function

Solution 1219648

Submitted on 25 Jun 2017 by Augusto Mazzei
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 all(y~=x(i)) y(end+1)=x(i) end end %This code written by profile_id 8179227 ' y = [] 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 = [] 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 = [] y = 0.0184 y = 0.0184 0.9872 y = 0.0184 0.9872 0.9458 y = 0.0184 0.9872 0.9458 0.2956 y = 0.0184 0.9872 0.9458 0.2956 0.7399 y = 0.0184 0.9872 0.9458 0.2956 0.7399 0.5205 y = 0.0184 0.9872 0.9458 0.2956 0.7399 0.5205 0.9070 y = 0.0184 0.9872 0.9458 0.2956 0.7399 0.5205 0.9070 0.5290 y = 0.0184 0.9872 0.9458 0.2956 0.7399 0.5205 0.9070 0.5290 0.9838 y = 0.0184 0.9872 0.9458 0.2956 0.7399 0.5205 0.9070 0.5290 0.9838 0.0217 y = 0.0184 0.9872 0.9458 0.2956 0.7399 0.5205 0.9070 0.5290 0.9838 0.0217 0.6608 y = 0.0184 0.9872 0.9458 0.2956 0.7399 0.5205 0.9070 0.5290 0.9838 0.0217 0.6608 0.3463 y = 0.0184 0.9872 0.9458 0.2956 0.7399 0.5205 0.9070 0.5290 0.9838 0.0217 0.6608 0.3463 0.4370 y = 0.0184 0.9872 0.9458 0.2956 0.7399 0.5205 0.9070 0.5290 0.9838 0.0217 0.6608 0.3463 0.4370 0.1157 y = 0.0184 0.9872 0.9458 0.2956 0.7399 0.5205 0.9070 0.5290 0.9838 0.0217 0.6608 0.3463 0.4370 0.1157 0.6118 y = 0.0184 0.9872 0.9458 0.2956 0.7399 0.5205 0.9070 0.5290 0.9838 0.0217 0.6608 0.3463 0.4370 0.1157 0.6118 0.9639 y = 0.0184 0.9872 0.9458 0.2956 0.7399 0.5205 0.9070 0.5290 0.9838 0.0217 0.6608 0.3463 0.4370 0.1157 0.6118 0.9639 0.1899 y = Columns 1 through 17 0.0184 0.9872 0.9458 0.2956 0.7399 0.5205 0.9070 0.5290 0.9838 0.0217 0.6608 0.3463 0.4370 0.1157 0.6118 0.9639 0.1899 Column 18 0.2635 y = Columns 1 through 17 0.0184 0.9872 0.9458 0.2956 0.7399 0.5205 0.9070 0.5290 0.9838 0.0217 0.6608 0.3463 0.4370 0.1157 0.6118 0.9639 0.1899 Columns 18 through 19 0.2635 0.9693 y = Columns 1 through 17 0.0184 0.9872 0.9458 0.2956 0.7399 0.5205 0.9070 0.5290 0.9838 0.0217 0.6608 0.3463 0.4370 0.1157 0.6118 0.9639 0.1899 Columns 18 through 20 0.2635 0.9693 0.4966 y = Columns 1 through 17 0.0184 0.9872 0.9458 0.2956 0.7399 0.5205 0.9070 0.5290 0.9838 0.0217 0.6608 0.3463 0.4370 0.1157 0.6118 0.9639 0.1899 Columns 18 through 21 0.2635 0.9693 0.4966 0.3143 y = Columns 1 through 17 0.0184 0.9872 0.9458 0.2956 0.7399 0.5205 0.9070 0.5290 0.9838 0.0217 0.6608 0.3463 0.4370 0.1157 0.6118 0.9639 0.1899 Columns 18 through 22 0.2635 0.9693 0.4966 0.3143 0.7799 y = Columns 1 through 17 0.0184 0.9872 0.9458 0.2956 0.7399 0.5205 0.9070 0.5290 0.9838 0.0217 0.6608 0.3463 0.4370 0.1157 0.6118 0.9639 0.1899 Columns 18 through 23 0.2635 0.9693 0.4966 0.3143 0.7799 0.3821 y = Columns 1 through 17 0.0184 0.9872 0.9458 0.2956 0.7399 0.5205 0.9070 0.5290 0.9838 0.0217 0.6608 0.3463 0.4370 0.1157 0.6118 0.9639 0.1899 Columns 18 through 24 0.2635 0.9693 0.4966 0.3143 0.7799 0.3821 0.5614 y = Columns 1 through 17 0.0184 0.9872 0.9458 0.2956 0.7399 0.5205 0.9070 0.5290 0.9838 0.0217 0.6608 0.3463 0.4370 0.1157 0.6118 0.9639 0.1899 Columns 18 through 25 0.2635 0.9693 0.4966 0.3143 0.7799 0.3821 0.5614 0.7514

Suggested Problems

More from this Author30

Community Treasure Hunt

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

Start Hunting!