Cody

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

Solution 1839798

Submitted on 5 Jun 2019 by Hans Kramer
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 9.9000 i = 2 numbers = 1 occurence = 1 i = 5 numbers = 1 2 occurence = 1 3 i = 7 numbers = 1 2 3 occurence = 1 3 2 i = 9 numbers = 1 2 3 7 occurence = 1 3 2 2 i = 10 numbers = 1 2 3 7 93 occurence = 1 3 2 2 1 y = 2 y = 2 3 7 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 9.9000 i = 3 numbers = 1 occurence = 2 i = 6 numbers = 1 2 occurence = 2 3 i = 8 numbers = 1 2 3 occurence = 2 3 2 i = 10 numbers = 1 2 3 7 occurence = 2 3 2 2 i = 11 numbers = 1 2 3 7 1 occurence = 2 3 2 2 1 i = 12 numbers = 1 2 3 7 1 93 occurence = 2 3 2 2 1 1 y = 2 y = 2 1 3 7 y = 2 1 3 7 1 93

3   Pass
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 9.9000 i = 2 numbers = 1 occurence = 1 i = 4 numbers = 1 0 occurence = 1 2 i = 6 numbers = 1 0 2 occurence = 1 2 2 i = 7 numbers = 1 0 2 -5 occurence = 1 2 2 1 i = 9 numbers = 1 0 2 -5 9 occurence = 1 2 2 1 2 i = 10 numbers = 1 0 2 -5 9 2 occurence = 1 2 2 1 2 1 i = 13 numbers = 1 0 2 -5 9 2 1 occurence = 1 2 2 1 2 1 3 i = 14 numbers = 1 0 2 -5 9 2 1 0 occurence = 1 2 2 1 2 1 3 1 i = 15 numbers = 1 0 2 -5 9 2 1 0 11 occurence = 1 2 2 1 2 1 3 1 1 y = 1 y = 1 0 2 9 y = 1 0 2 9 -5 0 1 2 11

4   Pass
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 9.9000 i = 2 numbers = 1 occurence = 1 i = 3 numbers = 1 0 occurence = 1 1 i = 5 numbers = 1 0 1 occurence = 1 1 2 i = 7 numbers = 1 0 1 0 occurence = 1 1 2 2 y = 1×0 empty double row vector y = 0 1 y = 0 1 0 1

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 9.9000 i = 2 numbers = 0 occurence = 1 i = 3 numbers = 0 1 occurence = 1 1 i = 5 numbers = 0 1 0 occurence = 1 1 2 i = 7 numbers = 0 1 0 1 occurence = 1 1 2 2 y = 1×0 empty double row vector y = 0 1 y = 0 1 0 1