Cody

# Problem 317. Find the stride of the longest skip sequence

Solution 1619843

Submitted on 31 Aug 2018 by Jens Kjærgaard Boldsen
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 5 3 11 7 2 4 9]; stride = 2; assert(isequal(skip_sequence_stride(a),stride))

maxlen = 5 stride = 1 maxlen = 6 stride = 2

2   Pass
a = [1:5:20 23:3:42 2:9:100]; stride = 9; assert(isequal(skip_sequence_stride(a),stride))

maxlen = 2 stride = 1 maxlen = 4 stride = 5 maxlen = 11 stride = 9

3   Pass
a = [2:2:22 13:17]; a = a(randperm(length(a))); stride = 2; assert(isequal(skip_sequence_stride(a),stride))

maxlen = 11 stride = 2

4   Pass
a = 37:5:120; a = a(randperm(length(a))); stride = 5; assert(isequal(skip_sequence_stride(a),stride))

maxlen = 17 stride = 5

5   Pass
a = [1:5 101:10:171 201:205]; a = a(randperm(length(a))); stride = 10; assert(isequal(skip_sequence_stride(a),stride))

maxlen = 5 stride = 1 maxlen = 8 stride = 10

6   Pass
a = [7:17:302 primes(300)]; a = sort(a); stride = 17; assert(isequal(skip_sequence_stride(a),stride))

maxlen = 2 stride = 1 maxlen = 3 stride = 11 maxlen = 4 stride = 45 maxlen = 5 stride = 6 maxlen = 7 stride = 48 maxlen = 18 stride = 17