Tutte le sfide
Facile 0 risolte 0% di accettazione

Pyramid Rows

Draw a right-aligned pyramid of # blocks.

Problema

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.

Vincoli

0 ≤ height ≤ 50

Esempi

Esempio 1
Input:
height = 3

Output atteso:
expected = ["  #", " ##", "###"]
Input:
long long height = 3;

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

Output atteso:
string[] expected = new string[] {"  #", " ##", "###"};

Spiegazione

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

Esempio 2
Input:
height = 1

Output atteso:
expected = ["#"]
Input:
long long height = 1;

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

Output atteso:
string[] expected = new string[] {"#"};

Spiegazione

A single row with one block: "#".

Riferimenti

Questa sfida è adattata per CodeUtility. Segui la traccia e i vincoli sopra.

Impara dagli altri

Soluzioni della community

Nessuna soluzione pubblicata. Risolvi questa sfida per condividere la prima.