Cody

Solution 1455332

Submitted on 4 Mar 2018 by Jiahang Li
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));

v = 2 3 8 6 5 ans = 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));

v = 2 3 8 6 5 ans = 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)));

v = 100 89 78 67 56 45 34 23 12 1 ans = 1 1 1 1 1 1 1 1 1 1 v = 100 89 78 67 56 45 34 23 12 1 ans = 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.

v = 1 -7 -8 -2 -6 0 3 -3 10 8 -1 7 -9 9 5 4 2 -4 6 -10 -5 ans = 3 11 5 5 6 5 4 6 2 4 7 4 4 5 5 3 3 2 7 5 4