Cody

# Problem 1485. Method of Common Differences part-1

Solution 1232465

Submitted on 16 Jul 2017 by Said BOUREZG
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
x = [1 4 9 16 25]; y_correct = [1 3 2]; assert(isequal(seq2commondiff(x),y_correct))

ans = 1 4 9 16 25 y = 1 ans = 3 5 7 9 y = 1 3 ans = 2 2 2 y = 1 3 2

2   Pass
x = [1 9 29 67 129 221]; y_correct = [1 8 12 6]; assert(isequal(seq2commondiff(x),y_correct))

ans = 1 9 29 67 129 221 y = 1 ans = 8 20 38 62 92 y = 1 8 ans = 12 18 24 30 y = 1 8 12 ans = 6 6 6 y = 1 8 12 6

3   Pass
x = [3 4 9 23 51 98 169 269 403 576]; y_correct = [3 1 4 5]; assert(isequal(seq2commondiff(x),y_correct))

ans = 3 4 9 23 51 98 169 269 403 576 y = 3 ans = 1 5 14 28 47 71 100 134 173 y = 3 1 ans = 4 9 14 19 24 29 34 39 y = 3 1 4 ans = 5 5 5 5 5 5 5 y = 3 1 4 5

4   Pass
x = [1 8 27 64 125 216]; y_correct = [1 7 12 6]; assert(isequal(seq2commondiff(x),y_correct))

ans = 1 8 27 64 125 216 y = 1 ans = 7 19 37 61 91 y = 1 7 ans = 12 18 24 30 y = 1 7 12 ans = 6 6 6 y = 1 7 12 6

5   Pass
x = [2 0 2 9 22 42]; y_correct = [2 -2 4 1]; assert(isequal(seq2commondiff(x),y_correct))

ans = 2 0 2 9 22 42 y = 2 ans = -2 2 7 13 20 y = 2 -2 ans = 4 5 6 7 y = 2 -2 4 ans = 1 1 1 y = 2 -2 4 1

6   Pass
x=[1 8 28 67 131 226] y_correct = [1 7 13 6]; assert(isequal(seq2commondiff(x),y_correct))

x = 1 8 28 67 131 226 ans = 1 8 28 67 131 226 y = 1 ans = 7 20 39 64 95 y = 1 7 ans = 13 19 25 31 y = 1 7 13 ans = 6 6 6 y = 1 7 13 6