Cody

# Problem 44416. Sum of adjacent elements in a vector

Solution 2623933

Submitted on 28 Jun 2020 by Ramesh Kumar V
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
filetext = fileread('summ.m'); assert(isempty(strfind(filetext, 'regexp')),'regexp hacks are forbidden')

2   Pass
v = randi(10, 1, randi(10)); s = summ(v); assert(length(s) == length(v) - 1)

m1 = logical 0 m = 1 n = 7 z = 13 z = 13 11 z = 13 11 11 z = 13 11 11 12 z = 13 11 11 12 9 z = 13 11 11 12 9 5 s = 13 11 11 12 9 5

3   Pass
v = 1:10; s_correct = 3:2:19; assert(isequal(summ(v),s_correct))

m1 = logical 0 m = 1 n = 10 z = 3 z = 3 5 z = 3 5 7 z = 3 5 7 9 z = 3 5 7 9 11 z = 3 5 7 9 11 13 z = 3 5 7 9 11 13 15 z = 3 5 7 9 11 13 15 17 z = 3 5 7 9 11 13 15 17 19 s = 3 5 7 9 11 13 15 17 19

4   Pass
v = [1; 2; 4; 4; 5; 8]; s_correct = [3; 6; 8; 9; 13]; assert(isequal(summ(v),s_correct))

m1 = logical 0 m = 6 n = 1 z = 3 z = 3 6 z = 3 6 8 z = 3 6 8 9 z = 3 6 8 9 13 s = 3 6 8 9 13