Cody

# Problem 1985. How unique?

Solution 2256429

Submitted on 5 May 2020
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   Fail
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));

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

Assertion failed.

2   Fail
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));

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

Assertion failed.

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

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

Assertion failed.

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.

U = -10 -9 -8 -7 -6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6 7 8 9 10 H = 5 4 9 4 7 2 4 5 2 7 7 6 5 5 3 4 8 1 3 4 5