Summary
Inspired by the recent popularity of ASCII art challenges, this challenge's purpose is to draw an ASCII checkerboard, like one on which Chess can be played.
Write a program that takes a positive integer n
as an argument, in stdin
, or as user input, and output an checkerboard with n
xn
squares, along with a border that is 1 character thick.
Each square should be 2x2 characters. The squares should follow the normal alternating white-black (white first, as in top-left corner) pattern of a checkerboard. White squares should be made out of space () characters, and black squares should be made out of pound (
#
) characters.
The border should be made out of dashes (-
) with a plus (+
) on the border or perpendicular point of a square.
Input
Positive integer in representing the number of squares (dimensions in squares) to draw in the checkerboard, with each square being 2x2 characters.
Example Results
n=2
+--+--+
| |##|
| |##|
+--+--+
|##| |
|##| |
+--+--+
n=3
+--+--+--+
| |##| |
| |##| |
+--+--+--+
|##| |##|
|##| |##|
+--+--+--+
| |##| |
| |##| |
+--+--+--+
n=4
+--+--+--+--+
| |##| |##|
| |##| |##|
+--+--+--+--+
|##| |##| |
|##| |##| |
+--+--+--+--+
| |##| |##|
| |##| |##|
+--+--+--+--+
|##| |##| |
|##| |##| |
+--+--+--+--+
... and so on.
Notes
- Trailing spaces and new lines are acceptable.
- You may write either an entire program or a function.
- No leading spaces.
- Your program should display correct results for n=15.
- For less-known esoteric languages and similar, provide a link to the language.
n=0
should produce+
. (optional, but highly recommended and encouraged.)- Shortest code in bytes wins, as this is code golf.