# Algebraic Pyramid Challenge

For the purpose of this challenge we will use algebraic pyramids pointing downwards (or upside down pyramids!).

The idea of this mathematical puzzle is to fill in all the bricks of a pyramid based on the following rule:

• To work out the value of a brick, add the values of the two adjacent bricks above it.

#### Python Challenge #1: Fix sized pyramids

This Python challenge will consist of writing a procedure that will take a list of values as a parameter, and will as a result generate and output an upside down pyramid where the top layer of the pyramid will contain all the values from the given list.

To simplify this problem, we will first assume that the list of number will always contains exactly 4 values.
For example:

The output of our procedure should be as follows:

#### Challenge #1: Python Code:

You will need to complete the following python code to work out and print all the layers of the pyramid.

#### Challenge #1: Test Plan

Check that your code is working using the following list of 4 values.

 Test # List Expected Output Pass/Fail? #1 [4,6,8,2] #2 [30,12,10,5] #3 [3,6,9,12]

#### Challenge #2: Using lists of different sizes

The second challenge consists of adapting the code from challenge 1 to make sure that it works for any list (of any length) of values.

#### Challenge #2: Test Plan

 Test # List Expected Output Pass/Fail? #1 [3,6,9] #2 [30,12,10,5] #3 [1,2,3,4,5,6]

Did you like this challenge?

Click on a star to rate it!

Average rating 3.6 / 5. Vote count: 7

No votes so far! Be the first to rate this post.

As you found this challenge interesting...