Cody

Problem 875. Return a list sorted by number of consecutive occurrences

Solution 2023346

Submitted on 15 Nov 2019
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
x = [1 2 2 2 3 3 7 7 93] y_correct1 = [2 3 7 1 93] ; assert(isequal(popularity_bis(x),y_correct1))

x = 1 2 2 2 3 3 7 7 93 x = 1.0000 2.0000 2.0000 2.0000 3.0000 3.0000 7.0000 7.0000 93.0000 1.1000 b = 1 1 a = 1 a = 2 a = 3 b = 1 1 3 2 a = 1 a = 2 b = 1 1 3 2 2 3 a = 1 a = 2 b = 1 1 3 2 2 3 2 7 a = 1 b = 1 1 3 2 2 3 2 7 1 93 a = 1 c = 1 2 3 7 93 B = 3 2 2 1 1 I = 2 3 4 1 5 b = 3 2 2 3 2 7 1 1 1 93 y = 2 3 7 1 93

2   Pass
x = [1 1 2 2 2 3 3 7 7 1 93]; y_correct2 = [2 1 3 7 1 93] ; assert(isequal(popularity_bis(x),y_correct2))

x = 1.0000 1.0000 2.0000 2.0000 2.0000 3.0000 3.0000 7.0000 7.0000 1.0000 93.0000 1.1000 a = 2 b = 2 1 a = 1 a = 2 a = 3 b = 2 1 3 2 a = 1 a = 2 b = 2 1 3 2 2 3 a = 1 a = 2 b = 2 1 3 2 2 3 2 7 a = 1 b = 2 1 3 2 2 3 2 7 1 1 a = 1 b = 2 1 3 2 2 3 2 7 1 1 1 93 a = 1 c = 1 2 3 7 1 93 B = 3 2 2 2 1 1 I = 2 1 3 4 5 6 b = 3 2 2 1 2 3 2 7 1 1 1 93 y = 2 1 3 7 1 93

3   Fail
x = [1 0 0 2 2 -5 9 9 2 1 1 1 0 11]; y_correct1 = [1 0 2 9 -5 0 1 2 11] ; assert(isequal(popularity_bis(x),y_correct1))

x = 1.0000 0 0 2.0000 2.0000 -5.0000 9.0000 9.0000 2.0000 1.0000 1.0000 1.0000 0 11.0000 1.1000 b = 1 1 a = 1 a = 2 b = 1 1 2 0 a = 1 a = 2 b = 1 1 2 0 2 2 a = 1 b = 1 1 2 0 2 2 1 -5 a = 1 a = 2 b = 1 1 2 0 2 2 1 -5 2 9 a = 1 b = 1 1 2 0 2 2 1 -5 2 9 1 2 a = 1 a = 2 a = 3 b = 1 1 2 0 2 2 1 -5 2 9 1 2 3 1 a = 1 b = 1 1 2 0 2 2 1 -5 2 9 1 2 3 1 1 0 a = 1 b = 1 1 2 0 2 2 1 -5 2 9 1 2 3 1 1 0 1 11 a = 1 c = 1 0 2 -5 9 2 1 0 11 B = 3 2 2 2 1 1 1 1 1 I = 7 2 3 5 1 4 6 8 9 b = 3 1 2 0 2 2 2 9 1 1 1 -5 1 2 1 0 1 11 y = 1 0 2 9 1 -5 2 0 11

Assertion failed.

4   Fail
x = [1 0 1 1 0 0]; y_correct0 = [0 1 0 1] ; assert(isequal(popularity_bis(x),y_correct0))

x = 1.0000 0 1.0000 1.0000 0 0 1.1000 b = 1 1 a = 1 b = 1 1 1 0 a = 1 a = 2 b = 1 1 1 0 2 1 a = 1 a = 2 b = 1 1 1 0 2 1 2 0 a = 1 c = 1 0 1 0 B = 2 2 1 1 I = 3 4 1 2 b = 2 1 2 0 1 1 1 0 y = 1 0 1 0

Assertion failed.

5   Pass
x = [0 1 0 0 1 1]; y_correct1 = [0 1 0 1] ; assert(isequal(popularity_bis(x),y_correct1))

x = 0 1.0000 0 0 1.0000 1.0000 1.1000 b = 1 0 a = 1 b = 1 0 1 1 a = 1 a = 2 b = 1 0 1 1 2 0 a = 1 a = 2 b = 1 0 1 1 2 0 2 1 a = 1 c = 0 1 0 1 B = 2 2 1 1 I = 3 4 1 2 b = 2 0 2 1 1 0 1 1 y = 0 1 0 1