Cody

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

Solution 1885500

Submitted on 27 Jul 2019 by Nikolaos Nikolaou
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))

t = 4 2 stride = 2

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

t = Columns 1 through 29 5 5 5 10 12 15 18 27 9 18 27 36 3 3 6 9 12 3 6 6 15 3 6 9 9 18 27 3 3 Columns 30 through 58 3 6 9 18 27 9 18 27 36 45 9 18 27 36 9 18 27 36 9 18 27 9 18 27 9 18 9 18 9 Column 59 9 stride = 9

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

t = 4 3 2 3 3 8 2 5 1 4 2 stride = 2

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

t = 5 35 15 10 25 5 5 15 15 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))

t = 10 30 stride = 10

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

t = Columns 1 through 29 45 6 12 12 18 18 42 48 54 84 96 12 17 17 30 34 34 34 34 51 51 68 68 72 85 12 17 17 30 Columns 30 through 58 34 34 34 34 51 51 68 68 72 85 6 30 30 32 60 78 90 30 48 48 62 90 12 12 42 80 28 54 60 Columns 59 through 87 30 52 78 17 17 34 51 68 85 85 54 72 74 84 22 36 66 30 38 6 17 30 34 34 51 66 68 68 85 Columns 88 through 116 85 6 17 30 34 34 51 66 68 68 85 85 18 32 60 12 14 28 42 60 66 18 30 48 60 17 17 34 51 Columns 117 through 145 51 51 51 68 8 24 6 14 4 30 42 42 72 72 4 36 60 17 17 34 34 51 68 68 24 30 48 54 54 Columns 146 through 174 17 17 34 51 68 42 48 60 30 42 17 34 34 51 51 17 34 34 51 51 18 60 17 34 51 12 50 6 46 Columns 175 through 203 20 30 17 34 34 51 14 48 30 30 42 17 17 34 30 17 17 34 34 30 30 17 17 34 17 17 6 12 18 Columns 204 through 213 17 6 12 6 6 12 17 6 12 2 stride = 17