Tutte le sfide
Facile 0 risolte 0% di accettazione

Hollow Square

Draw the outline of a square with * characters.

Problema

Draw a hollow square of side size: the first and last rows are all *, and the rows in between have * only at the two ends with spaces inside.

Implement hollow_square(size).

Input

size: The side length.

Output

Return the rows from top to bottom.

Vincoli

1 ≤ size ≤ 50

Esempi

Esempio 1
Input:
size = 4

Output atteso:
expected = ["****", "*  *", "*  *", "****"]
Input:
long long size = 4;

Output atteso:
std::vector<std::string> expected = {"****", "*  *", "*  *", "****"};
Input:
long size = 4;

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

Spiegazione

Rows are "****", "* *", "* *", "****".

Esempio 2
Input:
size = 1

Output atteso:
expected = ["*"]
Input:
long long size = 1;

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

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

Spiegazione

A 1×1 square is a single "*".

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.