Cody

Solution 2102008

Submitted on 22 Jan 2020 by Gianluca Marchetti
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
a = [1 2 2 2 1 3 2 1 4 5 1]; y_correct = 2; assert(isequal(longrun(a),y_correct))

lung = 11 j = 2 Else i = 2 j = 3 While eq = 1 j = 4 While eq = 2 j = 5 If val = 2 j = 6 Else i = 6 j = 7 Else i = 7 j = 8 Else i = 8 j = 9 Else i = 9 j = 10 Else i = 10 j = 11 Else i = 11 j = 12 Else i = 12

2   Pass
a = [1 1 1 2 2 2 3 3 3]; y_correct = [1 2 3]; assert(isequal(longrun(a),y_correct))

lung = 9 j = 2 While eq = 1 j = 3 While eq = 2 j = 4 If val = 1 j = 5 While eq = 1 j = 6 While eq = 2 j = 7 Elseif val = 1 2 i = 7 j = 8 While eq = 1 j = 9 While eq = 2 j = 10 Elseif val = 1 2 3 i = 10

3   Pass
a = [-2 -2 -2 -2 -1 0 3]; y_correct = -2; assert(isequal(longrun(a),y_correct))

lung = 7 j = 2 While eq = 1 j = 3 While eq = 2 j = 4 While eq = 3 j = 5 If val = -2 j = 6 Else i = 6 j = 7 Else i = 7 j = 8 Else i = 8

4   Pass
a=[0 1 1 1 0 2 2 0 1 1 1 0]; y_correct = [1 1]; assert(isequal(longrun(a),y_correct))

lung = 12 j = 2 Else i = 2 j = 3 While eq = 1 j = 4 While eq = 2 j = 5 If val = 1 j = 6 Else i = 6 j = 7 While eq = 1 j = 8 Else i = 7 j = 8 Else i = 8 j = 9 Else i = 9 j = 10 While eq = 1 j = 11 While eq = 2 j = 12 Elseif val = 1 1 i = 12 j = 13 Else i = 13

5   Pass
a=[3 3 3 2 2 1 6]'; y_correct=3; assert(isequal(longrun(a),y_correct))

lung = 7 j = 2 While eq = 1 j = 3 While eq = 2 j = 4 If val = 3 j = 5 While eq = 1 j = 6 Else i = 5 j = 6 Else i = 6 j = 7 Else i = 7 j = 8 Else i = 8

6   Pass
a=[3 3 3 2 2 2 1 6]'; y_correct=[3 2]'; assert(isequal(longrun(a),y_correct))

lung = 8 j = 2 While eq = 1 j = 3 While eq = 2 j = 4 If val = 3 j = 5 While eq = 1 j = 6 While eq = 2 j = 7 Elseif val = 3 2 i = 7 j = 8 Else i = 8 j = 9 Else i = 9

7   Pass
a=[1 2 3 4 5]'; y_correct=a; assert(isequal(longrun(a),y_correct))

lung = 5 j = 2 Else i = 2 j = 3 Else i = 3 j = 4 Else i = 4 j = 5 Else i = 5 j = 6 Else i = 6 val = 1 2 3 4 5