Cody

Solution 887807

Submitted on 9 May 2016 by Raviteja
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

This solution is outdated. To rescore this solution, sign in.

Test Suite

Test Status Code Input and Output
1   Pass
assert(P(4,3)==9)

y = 9

2   Pass
s=3; n=1:5; y_correct=[1 3 6 10 15]; assert(isequal(P(s,n),y_correct))

y = 1 y = 1 3 y = 1 3 6 y = 1 3 6 10 y = 1 3 6 10 15

3   Pass
s=3:6; n=4; Y_correct=[10 16 22 28]; assert(isequal(P(s,n),Y_correct))

y = 10 y = 10 16 y = 10 16 22 y = 10 16 22 28

4   Pass
s=randi([3 1000],1,10); n=1; y_correct=ones(1,10); assert(isequal(P(s,n),y_correct))

y = 1 y = 1 1 y = 1 1 1 y = 1 1 1 1 y = 1 1 1 1 1 y = 1 1 1 1 1 1 y = 1 1 1 1 1 1 1 y = 1 1 1 1 1 1 1 1 y = 1 1 1 1 1 1 1 1 1 y = 1 1 1 1 1 1 1 1 1 1

5   Pass
s=randi(1000,1,10)+2; n=5; y_correct=10*s-15; assert(isequal(P(s,n),y_correct))

y = 945 y = 945 4685 y = 945 4685 805 y = 945 4685 805 3285 y = 945 4685 805 3285 1985 y = 945 4685 805 3285 1985 4455 y = 945 4685 805 3285 1985 4455 5775 y = 945 4685 805 3285 1985 4455 5775 3715 y = 945 4685 805 3285 1985 4455 5775 3715 4295 y = 945 4685 805 3285 1985 4455 5775 3715 4295 4695

6   Pass
s=[5 6 7]'; n=[2 8 9]; y_correct=[5 92 117;6 120 153;7 148 189]; assert(isequal(P(s,n),y_correct))

y = 5 y = 5 92 y = 5 92 117 y = 5 92 117 6 0 0 y = 5 92 117 6 120 0 y = 5 92 117 6 120 153 y = 5 92 117 6 120 153 7 0 0 y = 5 92 117 6 120 153 7 148 0 y = 5 92 117 6 120 153 7 148 189

7   Pass
s=randi([3,1000]); n=randi([3,1000]); assert(P(s+1,n+1)-P(s,n+1)==P(3,n))

y = 25095381 y = 24720836 y = 374545