簡単 0件解決済み 正答率0%

Pyramid Rows

Draw a right-aligned pyramid of # blocks.

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.

制約

0 ≤ height ≤ 50

例

例 1
入力:
height = 3

期待される出力:
expected = ["  #", " ##", "###"]
入力:
long long height = 3;

期待される出力:
std::vector<std::string> expected = {"  #", " ##", "###"};
入力:
long height = 3;

期待される出力:
string[] expected = new string[] {"  #", " ##", "###"};

解説

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

例 2
入力:
height = 1

期待される出力:
expected = ["#"]
入力:
long long height = 1;

期待される出力:
std::vector<std::string> expected = {"#"};
入力:
long height = 1;

期待される出力:
string[] expected = new string[] {"#"};

解説

A single row with one block: "#".

参考資料

この課題はCodeUtility用に調整されています。上記の説明と制約に従ってください。

他の人の解答から学ぶ

コミュニティの解答

まだ公開された解答がありません。この課題を解いて最初の解答を共有しましょう。