Cody

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

Solution 1518020

Submitted on 5 May 2018 by Shreyash Singh
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))

a = 1 2 3 4 5 7 9 11

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

a = 1 2 6 11 11 16 20 23 26 29 29 32 35 38 38 41 47 56 65 74 83 92

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

a = 2 4 6 8 10 12 13 14 14 15 16 16 17 18 20 22

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

a = 37 42 47 52 57 62 67 72 77 82 87 92 97 102 107 112 117

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

a = 1 2 3 4 5 101 111 121 131 141 151 161 171 201 202 203 204 205

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

a = Columns 1 through 30 2 3 5 7 7 11 13 17 19 23 24 29 31 37 41 41 43 47 53 58 59 61 67 71 73 75 79 83 89 92 Columns 31 through 60 97 101 103 107 109 109 113 126 127 131 137 139 143 149 151 157 160 163 167 173 177 179 181 191 193 194 197 199 211 211 Columns 61 through 80 223 227 228 229 233 239 241 245 251 257 262 263 269 271 277 279 281 283 293 296