Facile 0 résolus 0 % de réussite

Pyramid Rows

Draw a right-aligned pyramid of # blocks.

Problème

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.

Contraintes

0 ≤ height ≤ 50

Exemples

Exemple 1
Entrée :
height = 3

Sortie attendue :
expected = ["  #", " ##", "###"]
Entrée :
long long height = 3;

Sortie attendue :
std::vector<std::string> expected = {"  #", " ##", "###"};
Entrée :
long height = 3;

Sortie attendue :
string[] expected = new string[] {"  #", " ##", "###"};

Explication

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

Exemple 2
Entrée :
height = 1

Sortie attendue :
expected = ["#"]
Entrée :
long long height = 1;

Sortie attendue :
std::vector<std::string> expected = {"#"};
Entrée :
long height = 1;

Sortie attendue :
string[] expected = new string[] {"#"};

Explication

A single row with one block: "#".

Références

Ce défi a été adapté pour CodeUtility. Suivez l'énoncé et les contraintes ci-dessus.

Apprenez des autres

Solutions de la communauté

Aucune solution publiée pour l'instant. Résolvez ce défi pour partager la première.