Skip to main content
2 of 2
reduce <3
bobtt
  • 73
  • 8

if you want to use numpy

A=np.array([80, 12, 14, 5, 70, 9, 26, 30, 8, 12, 16, 15]) print reduce(lambda x,y: x + [sum(y)], np.array(zip(A,A[1:],A[2:],A[3:])).tolist(),[]) 

output

[111, 101, 98, 110, 135, 73, 76, 66, 51]

bobtt
  • 73
  • 8