Cody

# Problem 1486. Method of Common Differences part-2

Solution 1369418

Submitted on 5 Dec 2017 by David Verrelli
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 3 2]; n=5; y_correct = [1 4 9 16 25]; assert(isequal(commondiff2seq(x,n),y_correct))

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

2   Pass
x = [1 4 6]; n=6; y_correct = [1 5 15 31 53 81]; assert(isequal(commondiff2seq(x,n),y_correct))

y = 6 6 6 6 y = 4 10 16 22 28 y = 1 5 15 31 53 81

3   Pass
x = [10 -4 4]; n=7; y_correct = [10 6 6 10 18 30 46]; assert(isequal(commondiff2seq(x,n),y_correct))

y = 4 4 4 4 4 y = -4 0 4 8 12 16 y = 10 6 6 10 18 30 46

4   Pass
x = [100 10 -5]; n=5; y_correct = [100 110 115 115 110]; assert(isequal(commondiff2seq(x,n),y_correct))

y = -5 -5 -5 y = 10 5 0 -5 y = 100 110 115 115 110

5   Pass
x = [0 -10 4 -2 6]; n=10; y_correct = [ 0 -10 -16 -20 -18 0 50 154 340 642]; assert(isequal(commondiff2seq(x,n),y_correct))

y = 6 6 6 6 6 6 y = -2 4 10 16 22 28 34 y = 4 2 6 16 32 54 82 116 y = -10 -6 -4 2 18 50 104 186 302 y = 0 -10 -16 -20 -18 0 50 154 340 642

6   Pass
x = [3 0]; n=4; y_correct = [3 3 3 3 ]; assert(isequal(commondiff2seq(x,n),y_correct))

y = 0 0 0 y = 3 3 3 3

7   Pass
x = [6 1]; n=4; y_correct = [6 7 8 9]; assert(isequal(commondiff2seq(x,n),y_correct))

y = 1 1 1 y = 6 7 8 9

8   Pass
x = [-10 1 -5 2]; n=10; y_correct = [-10 -9 -13 -20 -28 -35 -39 -38 -30 -13]; assert(isequal(commondiff2seq(x,n),y_correct))

y = 2 2 2 2 2 2 2 y = -5 -3 -1 1 3 5 7 9 y = 1 -4 -7 -8 -7 -4 1 8 17 y = -10 -9 -13 -20 -28 -35 -39 -38 -30 -13

9   Pass
x = [ 1 3 -1 -2 2 1]; n=10; y_correct = [ 1 4 6 5 1 -3 0 22 81 202]; assert(isequal(commondiff2seq(x,n),y_correct))

y = 1 1 1 1 1 y = 2 3 4 5 6 7 y = -2 0 3 7 12 18 25 y = -1 -3 -3 0 7 19 37 62 y = 3 2 -1 -4 -4 3 22 59 121 y = 1 4 6 5 1 -3 0 22 81 202

10   Pass
x = [0 0 0]; n=5; y_correct = [0 0 0 0 0]; assert(isequal(commondiff2seq(x,n),y_correct))

y = 0 0 0 y = 0 0 0 0 y = 0 0 0 0 0