if you want to use numpy
A=np.array([80, 12, 14, 5, 70, 9, 26, 30, 8, 12, 16, 15]) print [sumreduce(x)lambda forx,y: x in+ [sum(y)], np.array(zip(A,A[1:],A[2:],A[3:])).tolist()],[]) output
[111, 101, 98, 110, 135, 73, 76, 66, 51]
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about CollectivesStack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
Explore Stack Internalif you want to use numpy
A=np.array([80, 12, 14, 5, 70, 9, 26, 30, 8, 12, 16, 15]) print [sumreduce(x)lambda forx,y: x in+ [sum(y)], np.array(zip(A,A[1:],A[2:],A[3:])).tolist()],[]) output
[111, 101, 98, 110, 135, 73, 76, 66, 51]
if you want to use numpy
A=np.array([80, 12, 14, 5, 70, 9, 26, 30, 8, 12, 16, 15]) print [sum(x) for x in np.array(zip(A,A[1:],A[2:],A[3:])).tolist()] output
[111, 101, 98, 110, 135, 73, 76, 66, 51]
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]