Cody

# Problem 672. Longest run of consecutive numbers

Solution 2145316

Submitted on 29 Feb 2020 by Julián Esteban Olejua Pinto
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))

sza = 1 11 x = 1 y = 1 A = 0 1 A = 1 1 x = 2 A = 1 1 2 0 A = 1 1 2 1 A = 1 1 2 1 A = 1 1 2 2 A = 1 1 2 2 A = 1 1 2 3 x = 3 A = 1 1 2 3 1 0 A = 1 1 2 3 1 1 x = 4 A = 1 1 2 3 1 1 3 0 A = 1 1 2 3 1 1 3 1 x = 5 A = 1 1 2 3 1 1 3 1 2 0 A = 1 1 2 3 1 1 3 1 2 1 x = 6 A = 1 1 2 3 1 1 3 1 2 1 1 0 A = 1 1 2 3 1 1 3 1 2 1 1 1 x = 7 A = 1 1 2 3 1 1 3 1 2 1 1 1 4 0 A = 1 1 2 3 1 1 3 1 2 1 1 1 4 1 x = 8 A = 1 1 2 3 1 1 3 1 2 1 1 1 4 1 5 0 A = 1 1 2 3 1 1 3 1 2 1 1 1 4 1 5 1 x = 9 A = 1 1 2 3 1 1 3 1 2 1 1 1 4 1 5 1 1 0 A = 1 1 2 3 1 1 3 1 2 1 1 1 4 1 5 1 1 1 r = 3 t = 2 y = 2 val = 2

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

sza = 1 9 x = 1 y = 1 A = 0 1 A = 1 1 A = 1 2 A = 1 2 A = 1 3 x = 2 A = 1 3 2 0 A = 1 3 2 1 A = 1 3 2 1 A = 1 3 2 2 A = 1 3 2 2 A = 1 3 2 3 x = 3 A = 1 3 2 3 3 0 A = 1 3 2 3 3 1 A = 1 3 2 3 3 1 A = 1 3 2 3 3 2 A = 1 3 2 3 3 2 A = 1 3 2 3 3 3 r = 3 t = 1 y = 2 t = 1 2 y = 3 t = 1 2 3 y = 4 val = 1 2 3

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

sza = 1 7 x = 1 y = 1 A = 0 1 A = -2 1 A = -2 2 A = -2 2 A = -2 3 A = -2 3 A = -2 4 x = 2 A = -2 4 -1 0 A = -2 4 -1 1 x = 3 A = -2 4 -1 1 0 0 A = -2 4 -1 1 0 1 x = 4 A = -2 4 -1 1 0 1 3 0 A = -2 4 -1 1 0 1 3 1 r = 4 t = -2 y = 2 val = -2

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))

sza = 1 12 x = 1 y = 1 A = 0 1 A = 0 1 x = 2 A = 0 1 1 0 A = 0 1 1 1 A = 0 1 1 1 A = 0 1 1 2 A = 0 1 1 2 A = 0 1 1 3 x = 3 A = 0 1 1 3 0 0 A = 0 1 1 3 0 1 x = 4 A = 0 1 1 3 0 1 2 0 A = 0 1 1 3 0 1 2 1 A = 0 1 1 3 0 1 2 1 A = 0 1 1 3 0 1 2 2 x = 5 A = 0 1 1 3 0 1 2 2 0 0 A = 0 1 1 3 0 1 2 2 0 1 x = 6 A = 0 1 1 3 0 1 2 2 0 1 1 0 A = 0 1 1 3 0 1 2 2 0 1 1 1 A = 0 1 1 3 0 1 2 2 0 1 1 1 A = 0 1 1 3 0 1 2 2 0 1 1 2 A = 0 1 1 3 0 1 2 2 0 1 1 2 A = 0 1 1 3 0 1 2 2 0 1 1 3 x = 7 A = 0 1 1 3 0 1 2 2 0 1 1 3 0 0 A = 0 1 1 3 0 1 2 2 0 1 1 3 0 1 r = 3 t = 1 y = 2 t = 1 1 y = 3 val = 1 1

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

sza = 7 1 x = 1 y = 1 A = 0 1 A = 3 1 A = 3 2 A = 3 2 A = 3 3 x = 2 A = 3 3 2 0 A = 3 3 2 1 A = 3 3 2 1 A = 3 3 2 2 x = 3 A = 3 3 2 2 1 0 A = 3 3 2 2 1 1 x = 4 A = 3 3 2 2 1 1 6 0 A = 3 3 2 2 1 1 6 1 r = 3 t = 3 y = 2 val = 3

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

sza = 8 1 x = 1 y = 1 A = 0 1 A = 3 1 A = 3 2 A = 3 2 A = 3 3 x = 2 A = 3 3 2 0 A = 3 3 2 1 A = 3 3 2 1 A = 3 3 2 2 A = 3 3 2 2 A = 3 3 2 3 x = 3 A = 3 3 2 3 1 0 A = 3 3 2 3 1 1 x = 4 A = 3 3 2 3 1 1 6 0 A = 3 3 2 3 1 1 6 1 r = 3 t = 3 y = 2 t = 3 2 y = 3 val = 3 2

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

sza = 5 1 x = 1 y = 1 A = 0 1 A = 1 1 x = 2 A = 1 1 2 0 A = 1 1 2 1 x = 3 A = 1 1 2 1 3 0 A = 1 1 2 1 3 1 x = 4 A = 1 1 2 1 3 1 4 0 A = 1 1 2 1 3 1 4 1 x = 5 A = 1 1 2 1 3 1 4 1 5 0 A = 1 1 2 1 3 1 4 1 5 1 r = 1 t = 1 y = 2 t = 1 2 y = 3 t = 1 2 3 y = 4 t = 1 2 3 4 y = 5 t = 1 2 3 4 5 y = 6 val = 1 2 3 4 5