0
\$\begingroup\$

You have to write a function/program that will draw an ASCII art of a square made with numbers.

Challenge

This program will take one input n as a positive integer and draw a hollow square using this number. The inside must be filled with spaces. The borders also must have the same width. The width and height of the square must also be equal.

Examples

n=1

1

n=2

22
22

n=3

333
333
333

n=10

10101010101010101010
10101010101010101010
10                10
10                10
10                10
10                10
10                10
10                10
10                10
10                10
10                10
10                10
10                10
10                10
10                10
10                10
10                10
10                10
10101010101010101010
10101010101010101010

As you can see, this is quite straightforward until you reach the double digits. Since 10 has two digits, you must add an extra inside layer to make all the borders have width 2.

So, each square will be nxn, plus the appropriate border.

This is , so lowest byte count wins. Tie-breaker is earlier submission.

\$\endgroup\$
10
  • \$\begingroup\$ What are the limits? \$\endgroup\$
    – Bálint
    May 6 '16 at 14:18
  • \$\begingroup\$ @CᴏɴᴏʀO'Bʀɪᴇɴ I don't think the additional lines on the top and bottom border are enough of a difference for this to not be a duplicate. \$\endgroup\$ May 6 '16 at 14:21
  • \$\begingroup\$ @TimmyD I think so too, I said that to be safe. \$\endgroup\$ May 6 '16 at 14:22
  • \$\begingroup\$ Hmm, I did not realize that there was already a question like this already. \$\endgroup\$
    – ericw31415
    May 6 '16 at 14:28
  • 1
    \$\begingroup\$ @EᴀsᴛᴇʀʟʏIʀᴋ Questions closed as duplicates can be reopened; it's not impossible. If the post is edited such that it differs significantly from the post it was marked a duplicate of, it should absolutely make it back into the review queue. That's what the review queue is for. \$\endgroup\$
    – Alex A.
    May 6 '16 at 18:21