Cody

Solution 805568

Submitted on 13 Jan 2016 by Zikobrelli
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
%% A = [2 2 2 3 3 2 3 8 6 5 6]; [U, H] = hunique(A); U_ok = [2 3 8 6 5]; H_ok = [4 3 1 2 1]; assert(isequal(U,U_ok)); assert(isequal(H,H_ok));

H = [] U = 2 H = 4 U = 2 3 H = 4 3 U = 2 3 8 H = 4 3 1 U = 2 3 8 6 H = 4 3 1 2 U = 2 3 8 6 5 H = 4 3 1 2 1

2   Pass
%% A = [2 2 2 3 3 2 3 8 6 5 6 8]; [U, H] = hunique(A); U_ok = [2 3 8 6 5]; H_ok = [4 3 2 2 1]; assert(isequal(U,U_ok)); assert(isequal(H,H_ok));

H = [] U = 2 H = 4 U = 2 3 H = 4 3 U = 2 3 8 H = 4 3 2 U = 2 3 8 6 H = 4 3 2 2 U = 2 3 8 6 5 H = 4 3 2 2 1

3   Pass
%% A = 100:-11:1; assert(isequal(hunique(A),A)); [~,H] = hunique(A); assert(isequal(H,ones(1,10)));

H = [] U = 100 H = 1 U = 100 89 H = 1 1 U = 100 89 78 H = 1 1 1 U = 100 89 78 67 H = 1 1 1 1 U = 100 89 78 67 56 H = 1 1 1 1 1 U = 100 89 78 67 56 45 H = 1 1 1 1 1 1 U = 100 89 78 67 56 45 34 H = 1 1 1 1 1 1 1 U = 100 89 78 67 56 45 34 23 H = 1 1 1 1 1 1 1 1 U = 100 89 78 67 56 45 34 23 12 H = 1 1 1 1 1 1 1 1 1 U = 100 89 78 67 56 45 34 23 12 1 H = 1 1 1 1 1 1 1 1 1 1 H = [] U = 100 H = 1 U = 100 89 H = 1 1 U = 100 89 78 H = 1 1 1 U = 100 89 78 67 H = 1 1 1 1 U = 100 89 78 67 56 H = 1 1 1 1 1 U = 100 89 78 67 56 45 H = 1 1 1 1 1 1 U = 100 89 78 67 56 45 34 H = 1 1 1 1 1 1 1 U = 100 89 78 67 56 45 34 23 H = 1 1 1 1 1 1 1 1 U = 100 89 78 67 56 45 34 23 12 H = 1 1 1 1 1 1 1 1 1 U = 100 89 78 67 56 45 34 23 12 1 H = 1 1 1 1 1 1 1 1 1 1

4   Pass
%% A = randi([-10 10],1,100); [U,H] = hunique(A); assert(sum(H)==numel(A)); assert(isequal(unique(A),sort(U))); % number of test cases may increace in the future. % any proposals of test cases warmly welcome.

H = [] U = -6 H = 7 U = -6 -1 H = 7 9 U = -6 -1 10 H = 7 9 5 U = -6 -1 10 3 H = 7 9 5 7 U = -6 -1 10 3 -2 H = 7 9 5 7 7 U = -6 -1 10 3 -2 0 H = 7 9 5 7 7 4 U = -6 -1 10 3 -2 0 8 H = 7 9 5 7 7 4 3 U = -6 -1 10 3 -2 0 8 5 H = 7 9 5 7 7 4 3 7 U = -6 -1 10 3 -2 0 8 5 6 H = 7 9 5 7 7 4 3 7 4 U = -6 -1 10 3 -2 0 8 5 6 -10 H = 7 9 5 7 7 4 3 7 4 2 U = -6 -1 10 3 -2 0 8 5 6 -10 1 H = 7 9 5 7 7 4 3 7 4 2 5 U = -6 -1 10 3 -2 0 8 5 6 -10 1 -5 H = 7 9 5 7 7 4 3 7 4 2 5 6 U = -6 -1 10 3 -2 0 8 5 6 -10 1 -5 9 H = 7 9 5 7 7 4 3 7 4 2 5 6 4 U = -6 -1 10 3 -2 0 8 5 6 -10 1 -5 9 2 H = 7 9 5 7 7 4 3 7 4 2 5 6 4 2 U = -6 -1 10 3 -2 0 8 5 6 -10 1 -5 9 2 -9 H = 7 9 5 7 7 4 3 7 4 2 5 6 4 2 5 U = -6 -1 10 3 -2 0 8 5 6 -10 1 -5 9 2 -9 4 H = 7 9 5 7 7 4 3 7 4 2 5 6 4 2 5 3 U = Columns 1 through 16 -6 -1 10 3 -2 0 8 5 6 -10 1 -5 9 2 -9 4 Column 17 -8 H = Columns 1 through 16 7 9 5 7 7 4 3 7 4 2 5 6 4 2 5 3 Column 17 5 U = Columns 1 through 16 -6 -1 10 3 -2 0 8 5 6 -10 1 -5 9 2 -9 4 Columns 17 through 18 -8 -3 H = Columns 1 through 16 7 9 5 7 7 4 3 7 4 2 5 6 4 2 5 3 Columns 17 through 18 5 7 U = Columns 1 through 16 -6 -1 10 3 -2 0 8 5 6 -10 1 -5 9 2 -9 4 Columns 17 through 19 -8 -3 7 H = Columns 1 through 16 7 9 5 7 7 4 3 7 4 2 5 6 4 2 5 3 Columns 17 through 19 5 7 3 U = Columns 1 through 16 -6 -1 10 3 -2 0 8 5 6 -10 1 -5 9 2 -9 4 Columns 17 through 20 -8 -3 7 -7 H = Columns 1 through 16 7 9 5 7 7 4 3 7 4 2 5 6 4 2 5 3 Columns 17 through 20 5 7 3 2 U = Columns 1 through 16 -6 -1 10 3 -2 0 8 5 6 -10 1 -5 9 2 -9 4 Columns 17 through 21 -8 -3 7 -7 -4 H = Columns 1 through 16 7 9 5 7 7 4 3 7 4 2 5 6 4 2 5 3 Columns 17 through 21 5 7 3 2 3