Cody

# Problem 44510. Besson Ranks

Solution 3341928

Submitted on 23 Oct 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
x = [1 2]; y_correct = [1 2]; assert(isequal(bessonRanks(x),y_correct))

ans = 1 2 1 2 1 2 t = 1 s = 1 t = 2 s = 2

Assertion failed.

2   Fail
x = [1 1]; % (1 + 2)/2 = 1.5 y_correct = [1.5 1.5]; assert(isequal(bessonRanks(x),y_correct))

ans = 1.0000 1.0000 1.0000 1.0000 1.5000 1.5000 t = 1 2 s = 1 2 t = 1 2 s = 1 2

Assertion failed.

3   Fail
x = [1 1 1]; % (1 + 2 + 3)/3 = 2 y_correct = [2 2 2]; assert(isequal(bessonRanks(x),y_correct))

ans = 1 1 1 1 1 1 2 2 2 t = 1 2 3 s = 1 2 3 t = 1 2 3 s = 1 2 3 t = 1 2 3 s = 1 2 3

Assertion failed.

4   Fail
x = [1 1 1 1]; % (1 + 2 + 3 + 4)/4 = 2.5 y_correct = [2.5 2.5 2.5 2.5]; assert(isequal(bessonRanks(x),y_correct))

ans = 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 2.5000 2.5000 2.5000 2.5000 t = 1 2 3 4 s = 1 2 3 4 t = 1 2 3 4 s = 1 2 3 4 t = 1 2 3 4 s = 1 2 3 4 t = 1 2 3 4 s = 1 2 3 4

Assertion failed.

5   Fail
x = [1 1 1 1 1]; % (1 + 2 + 3 + 4 + 5)/5=3 y_correct = [3 3 3 3 3]; assert(isequal(bessonRanks(x),y_correct))

ans = 1 1 1 1 1 1 1 1 1 1 3 3 3 3 3 t = 1 2 3 4 5 s = 1 2 3 4 5 t = 1 2 3 4 5 s = 1 2 3 4 5 t = 1 2 3 4 5 s = 1 2 3 4 5 t = 1 2 3 4 5 s = 1 2 3 4 5 t = 1 2 3 4 5 s = 1 2 3 4 5

Assertion failed.

6   Fail
x = [1 2 2 3]; y_correct = [1 2.5 2.5 4]; assert(isequal(bessonRanks(x),y_correct))

ans = 1.0000 2.0000 2.0000 3.0000 1.0000 2.0000 2.0000 3.0000 1.0000 2.5000 2.5000 4.0000 t = 1 s = 1 t = 2 3 s = 2 3 t = 2 3 s = 2 3 t = 4 s = 4

Assertion failed.

7   Fail
x = [1 2 3 3]; y_correct = [1 2 3.5 3.5]; % 7/2 = 3.5 assert(isequal(bessonRanks(x),y_correct))

ans = 1.0000 2.0000 3.0000 3.0000 1.0000 2.0000 3.0000 3.0000 1.0000 2.0000 3.5000 3.5000 t = 1 s = 1 t = 2 s = 2 t = 3 4 s = 3 4 t = 3 4 s = 3 4

Assertion failed.

8   Fail
x = [1 1 2 3]; y_correct = [1.5 1.5 3 4]; % (1+2)/2 = 1.5 assert(isequal(bessonRanks(x),y_correct))

ans = 1.0000 1.0000 2.0000 3.0000 1.0000 1.0000 2.0000 3.0000 1.5000 1.5000 3.0000 4.0000 t = 1 2 s = 1 2 t = 1 2 s = 1 2 t = 3 s = 3 t = 4 s = 4

Assertion failed.

9   Fail
x = [1 1 2 2]; y_correct = [1.5 1.5 3.5 3.5]; % (1+2)/2 = 1.5 and (3+4)/2=3.5 assert(isequal(bessonRanks(x),y_correct))

ans = 1.0000 1.0000 2.0000 2.0000 1.0000 1.0000 2.0000 2.0000 1.5000 1.5000 3.5000 3.5000 t = 1 2 s = 1 2 t = 1 2 s = 1 2 t = 3 4 s = 3 4 t = 3 4 s = 3 4

Assertion failed.

10   Fail
x = [6.8 7.2 6.8 5.4 6.3]; y_correct = [3.5 5 3.5 1 2]; assert(isequal(bessonRanks(x),y_correct))

ans = 6.8000 7.2000 6.8000 5.4000 6.3000 5.4000 6.3000 6.8000 6.8000 7.2000 1.0000 2.0000 3.5000 3.5000 5.0000 t = 3 4 s = 4 t = 5 s = 5 t = 3 4 s = 1 3 t = 1 s = 1 3 t = 2 s = 2

Assertion failed.

11   Fail
x = [6.8 7.2 6.8 5.4 6.3]; y_correct = [3.5 5 3.5 1 2]; assert(isequal(bessonRanks(x),y_correct))

ans = 6.8000 7.2000 6.8000 5.4000 6.3000 5.4000 6.3000 6.8000 6.8000 7.2000 1.0000 2.0000 3.5000 3.5000 5.0000 t = 3 4 s = 4 t = 5 s = 5 t = 3 4 s = 1 3 t = 1 s = 1 3 t = 2 s = 2

Assertion failed.

12   Fail
x = [9 5 9 4 3 4 1 9 9 2 4 ]; y_correct = [9.5 7 9.5 5 3 5 1 9.5 9.5 2 5]; assert(isequal(bessonRanks(x),y_correct))

ans = 9.0000 5.0000 9.0000 4.0000 3.0000 4.0000 1.0000 9.0000 9.0000 2.0000 4.0000 1.0000 2.0000 3.0000 4.0000 4.0000 4.0000 5.0000 9.0000 9.0000 9.0000 9.0000 1.0000 2.0000 3.0000 5.0000 5.0000 5.0000 7.0000 9.5000 9.5000 9.5000 9.5000 t = 8 9 10 11 s = 7 t = 7 s = 10 t = 8 9 10 11 s = 5 t = 4 5 6 s = 4 6 11 t = 3 s = 4 6 11 t = 4 5 6 s = 4 6 11 t = 1 s = 2 t = 8 9 10 11 s = 1 3 8 9 t = 8 9 10 11 s = 1 3 8 9 t = 2 s = 1 3 8 9 t = 4 5 6 s = 1 3 8 9

Assertion failed.

13   Fail
x = [2 2 2 3 3 3 4 4 4 ]; y_correct = [2 2 2 5 5 5 8 8 8 ]; assert(isequal(bessonRanks(x),y_correct))

ans = 2 2 2 3 3 3 4 4 4 2 2 2 3 3 3 4 4 4 2 2 2 5 5 5 8 8 8 t = 1 2 3 s = 1 2 3 t = 1 2 3 s = 1 2 3 t = 1 2 3 s = 1 2 3 t = 4 5 6 s = 4 5 6 t = 4 5 6 s = 4 5 6 t = 4 5 6 s = 4 5 6 t = 7 8 9 s = 7 8 9 t = 7 8 9 s = 7 8 9 t = 7 8 9 s = 7 8 9

Assertion failed.

14   Fail
x = [10 20 10 30 10 20 20 20 20 30]; y_correct = [2 6 2 9.5 2 6 6 6 6 9.5]; assert(isequal(bessonRanks(x),y_correct))

ans = 10.0000 20.0000 10.0000 30.0000 10.0000 20.0000 20.0000 20.0000 20.0000 30.0000 10.0000 10.0000 10.0000 20.0000 20.0000 20.0000 20.0000 20.0000 30.0000 30.0000 2.0000 2.0000 2.0000 6.0000 6.0000 6.0000 6.0000 6.0000 9.5000 9.5000 t = 1 2 3 s = 1 3 5 t = 4 5 6 7 8 s = 1 3 5 t = 1 2 3 s = 1 3 5 t = 9 10 s = 2 6 7 8 9 t = 1 2 3 s = 2 6 7 8 9 t = 4 5 6 7 8 s = 2 6 7 8 9 t = 4 5 6 7 8 s = 2 6 7 8 9 t = 4 5 6 7 8 s = 2 6 7 8 9 t = 4 5 6 7 8 s = 4 10 t = 9 10 s = 4 10

Assertion failed.

15   Fail
x = [2 5 1.7 4 5.5 5.5 1.7 2 5]; y_correct = [3.5 6.5 1.5 5 8.5 8.5 1.5 3.5 6.5]; assert(isequal(bessonRanks(x),y_correct))

ans = 2.0000 5.0000 1.7000 4.0000 5.5000 5.5000 1.7000 2.0000 5.0000 1.7000 1.7000 2.0000 2.0000 4.0000 5.0000 5.0000 5.5000 5.5000 1.5000 1.5000 3.5000 3.5000 5.0000 6.5000 6.5000 8.5000 8.5000 t = 3 4 s = 3 7 t = 6 7 s = 3 7 t = 1 2 s = 1 8 t = 5 s = 1 8 t = 8 9 s = 4 t = 8 9 s = 2 9 t = 1 2 s = 2 9 t = 3 4 s = 5 6 t = 6 7 s = 5 6

Assertion failed.

16   Fail
for idx = 1:20 x = rand(1); y_correct = [1]; assert(isequal(bessonRanks(x),y_correct)) end

ans = 0.6594 0.6594 1.0000 t = 1 s = 1

Assertion failed.

17   Pass
for idx = 1:30 k = randi([20 90]); n = randperm(k); [~, y_correct]= sort(n); end

18   Fail
x = [1 1 2 1 3 3 2]; y_correct = [2 2 4.5 2 6.5 6.5 4.5]; assert(isequal(bessonRanks(x),y_correct))

ans = 1.0000 1.0000 2.0000 1.0000 3.0000 3.0000 2.0000 1.0000 1.0000 1.0000 2.0000 2.0000 3.0000 3.0000 2.0000 2.0000 2.0000 4.5000 4.5000 6.5000 6.5000 t = 1 2 3 s = 1 2 4 t = 1 2 3 s = 1 2 4 t = 4 5 s = 1 2 4 t = 1 2 3 s = 3 7 t = 6 7 s = 3 7 t = 6 7 s = 5 6 t = 4 5 s = 5 6

Assertion failed.

### Community Treasure Hunt

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

Start Hunting!