Easy 0 solved 0% acceptance

Pyramid Rows

Draw a right-aligned pyramid of # blocks.

Problem

Draw a right-aligned pyramid like the one in Super Mario: row i (counting from 1) has height − i spaces followed by i # characters.

Implement pyramid_rows(height).

Input

height: The number of rows.

Output

Return the rows from top to bottom.

Constraints

0 ≤ height ≤ 50

Examples

Example 1
Input:
height = 3

Expected output:
expected = ["  #", " ##", "###"]
Input:
long long height = 3;

Expected output:
std::vector<std::string> expected = {"  #", " ##", "###"};
Input:
long height = 3;

Expected output:
string[] expected = new string[] {"  #", " ##", "###"};

Explanation

Rows are " #", " ##" and "###": each row has one more block and one less space.

Example 2
Input:
height = 1

Expected output:
expected = ["#"]
Input:
long long height = 1;

Expected output:
std::vector<std::string> expected = {"#"};
Input:
long height = 1;

Expected output:
string[] expected = new string[] {"#"};

Explanation

A single row with one block: "#".

References

This challenge is adapted for CodeUtility. Follow the statement and constraints above.

Learn from others

Community solutions

No published solutions yet. Solve this challenge to share the first one.