Quantcast
Viewing all articles
Browse latest Browse all 20

ICE: adding consecutive elements in an array

I was hoping to do something more complicated, but I ran out of time…

Here’s the exercise: Take an array and build a new array by adding consecutive elements in the original array.
For example, given this array:

1 3 2 4 7 5 6 9 11 1 3 9

construct this array:

1+3, 3+2, 2+4, 4+7, ..., 3+9

Image may be NSFW.
Clik here to view.
array_sum_consecutive_elements

Summing up three consecutive elements will hopefully be more interesting…


Image may be NSFW.
Clik here to view.
Image may be NSFW.
Clik here to view.

Viewing all articles
Browse latest Browse all 20

Trending Articles