Cody

Solution 466258

Submitted on 4 Jul 2014 by Nick
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_correct = [2 3 7 1 93]; assert(isequal(popularity(x),y_correct))

x = 1 2 2 2 3 3 7 7 93 k = 1 c = 1 k = 2 c = 1 3 k = 3 c = 1 3 3 k = 4 c = 1 3 3 3 k = 5 c = 1 3 3 3 2 k = 6 c = 1 3 3 3 2 2 k = 7 c = 1 3 3 3 2 2 2 k = 8 c = 1 3 3 3 2 2 2 2 k = 9 c = 1 3 3 3 2 2 2 2 1 k = 10 index = 0 1 1 1 0 0 0 0 0 y = 2 2 2 index = 0 0 0 0 1 1 1 1 0 y = 2 2 2 3 3 7 7 index = 1 0 0 0 0 0 0 0 1 y = 2 2 2 3 3 7 7 1 93 y = 2 3 7 1 93

2   Pass
%% x = [-1 19 20 -1 -1 87 19 34 19 -1 21 87 20 10 20 34 19 -1]; y_correct = [-1 19 20 34 87 10 21]; assert(isequal(popularity(x),y_correct))

k = 1 c = 5 k = 2 c = 5 4 k = 3 c = 5 4 3 k = 4 c = 5 4 3 5 k = 5 c = 5 4 3 5 5 k = 6 c = 5 4 3 5 5 2 k = 7 c = 5 4 3 5 5 2 4 k = 8 c = 5 4 3 5 5 2 4 2 k = 9 c = 5 4 3 5 5 2 4 2 4 k = 10 c = 5 4 3 5 5 2 4 2 4 5 k = 11 c = 5 4 3 5 5 2 4 2 4 5 1 k = 12 c = 5 4 3 5 5 2 4 2 4 5 1 2 k = 13 c = 5 4 3 5 5 2 4 2 4 5 1 2 3 k = 14 c = 5 4 3 5 5 2 4 2 4 5 1 2 3 1 k = 15 c = 5 4 3 5 5 2 4 2 4 5 1 2 3 1 3 k = 16 c = 5 4 3 5 5 2 4 2 4 5 1 2 3 1 3 2 k = 17 c = Columns 1 through 16 5 4 3 5 5 2 4 2 4 5 1 2 3 1 3 2 Column 17 4 k = 18 c = Columns 1 through 16 5 4 3 5 5 2 4 2 4 5 1 2 3 1 3 2 Columns 17 through 18 4 5 k = 19 index = Columns 1 through 16 1 0 0 1 1 0 0 0 0 1 0 0 0 0 0 0 Columns 17 through 18 0 1 y = -1 -1 -1 -1 -1 index = Columns 1 through 16 0 1 0 0 0 0 1 0 1 0 0 0 0 0 0 0 Columns 17 through 18 1 0 y = -1 -1 -1 -1 -1 19 19 19 19 index = Columns 1 through 16 0 0 1 0 0 0 0 0 0 0 0 0 1 0 1 0 Columns 17 through 18 0 0 y = -1 -1 -1 -1 -1 19 19 19 19 20 20 20 index = Columns 1 through 16 0 0 0 0 0 1 0 1 0 0 0 1 0 0 0 1 Columns 17 through 18 0 0 y = -1 -1 -1 -1 -1 19 19 19 19 20 20 20 34 34 87 87 index = Columns 1 through 16 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 Columns 17 through 18 0 0 y = Columns 1 through 16 -1 -1 -1 -1 -1 19 19 19 19 20 20 20 34 34 87 87 Columns 17 through 18 10 21 y = -1 19 20 34 87 10 21