Fácil 0 resueltos 0% de aceptación

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.

Restricciones

0 ≤ height ≤ 50

Ejemplos

Ejemplo 1
Entrada:
height = 3

Salida esperada:
expected = ["  #", " ##", "###"]
Entrada:
long long height = 3;

Salida esperada:
std::vector<std::string> expected = {"  #", " ##", "###"};
Entrada:
long height = 3;

Salida esperada:
string[] expected = new string[] {"  #", " ##", "###"};

Explicación

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

Ejemplo 2
Entrada:
height = 1

Salida esperada:
expected = ["#"]
Entrada:
long long height = 1;

Salida esperada:
std::vector<std::string> expected = {"#"};
Entrada:
long height = 1;

Salida esperada:
string[] expected = new string[] {"#"};

Explicación

A single row with one block: "#".

Referencias

Este reto está adaptado para CodeUtility. Sigue el enunciado y las restricciones indicadas arriba.

Aprende de otros

Soluciones de la comunidad

Aún no hay soluciones publicadas. Resuelve este reto para compartir la primera.