Pyramid Array coding challenge

Hello Everyone,
I am going to solve a coding porblem which is called Pyramid Array

I want from you to help me collect explain the problem as much as you can so I understand the problem very well and to get tips and hints that helps me before starting solving this challenge.

The link to the challenge:

I think the page you link to is pretty self explanatory. Look at their example and see if you can identify the pattern. Look at the value they have for pyramid(3). Notice how there are three elements in the resulting array, where the length of each array inside that array is incremented by one. So the first item has 1 element, the second array has 2 elements and the third item has 3 elements.

How does the number of nested arrays relate to the value passed into the function? How does the number of elements in each of those nested arrays relate to the value passed in? What would you expect pyramid(4) be? Possibly [ [1], [1,1], [1, 1, 1], [1, 1, 1, 1] ]?

Just take a minute to understand the pattern and then write the function to replicate the pattern. :slight_smile:

The visualisation on that page is a bit weird. I think the point is to build pyramids where each layer is bit wider than the one above.

Like so:

pyramid(1)

1

represented as [[1]], because there is 1 layer with one 1

pyramid(2)

 1
1 1

represented as [[1], [1,1]], because there is 1 layer with one 1, and 1 layer with 2 1s

pyramid(3)

  1
 1 1
1 1 1

represented as [[1], [1,1], [1,1,1]], because there is 1 layer with one 1, 1 layer with 2 1s, and 1 layer with 3 1s

and so on and so forth

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.