Back
Close

Pascal's Neighbor

Statement

 Goal

Pascal's neighbor likes triangles too! However, they do things in the opposite direction compared to their more famous neighbor. Given a list of integers, they add consecutive pairs of integers, row by row, until the triangle is reduced to one final integer sum. For example:

1 1 1 1 1 1 1 1
2 2 2
------> 4 4
8
Input
Line 1: N, the number of integers in the base of the triangle.
Line 2: N space-separated integers.
Output
A single integer representing the total at the peak of the triangle.
Constraints
0 < N < 50
Example
Input
5
0 1 2 3 4
Output
32

Game modes
Fastest, Shortest

Test cases
Test 1 Test
Input
5 0 1 2 3 4
Output
32

Validator 1 Validator
Input
5 4 3 2 1 0
Output
32

Test 2 Test
Input
1 1
Output
1

Validator 2 Validator
Input
1 0
Output
0

Test 3 Test
Input
9 100 274 309 412 876 1209 4287 8928 10529
Output
365029

Validator 3 Validator
Input
9 100 274 412 309 876 1209 4287 8928 10529
Output
362145

Test 4 Test
Input
5 2 -3 7 -1 12
Output
40

Validator 4 Validator
Input
5 -2 3 -7 1 -12
Output
-40

Test 5 Test
Input
50 1 3 4 6 7 7 8 10 11 12 13 14 16 17 18 19 21 22 24 25 27 27 28 29 31 31 33 34 36 37 39 39 39 39 39 39 40 41 42 43 44 44 45 46 48 49 50 52 52 53
Output
17571422465675398

Validator 5 Validator
Input
50 1 3 4 6 7 7 8 10 11 12 13 14 16 17 18 19 21 22 25 24 27 27 28 29 31 31 33 34 36 37 39 39 39 39 39 39 40 41 42 43 44 44 45 46 48 49 50 52 52 53
Output
17564125039263430

Solution language

Solution

Stub generator input