Easy 0 solved 0% acceptance

Hollow Square

Draw the outline of a square with * characters.

Problem

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.

Constraints

1 ≤ size ≤ 50

Examples

Example 1
Input:
size = 4

Expected output:
expected = ["****", "*  *", "*  *", "****"]
Input:
long long size = 4;

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

Expected output:
string[] expected = new string[] {"****", "*  *", "*  *", "****"};

Explanation

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

Example 2
Input:
size = 1

Expected output:
expected = ["*"]
Input:
long long size = 1;

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

Expected output:
string[] expected = new string[] {"*"};

Explanation

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

References

This challenge is adapted for CodeUtility. Follow the statement and constraints above.

Learn from others

Community solutions

No published solutions yet. Solve this challenge to share the first one.