Draw an ASCII Checkerboard

J, 24 bytes

An anonymous function:

2 2&$&.>@(' #'{~2|+/~@i.)

Usage:

   f =: 2 2&$&.>@(' #'{~2|+/~@i.)
   f 4
+--+--+--+--+
|  |##|  |##|
|  |##|  |##|
+--+--+--+--+
|##|  |##|  |
|##|  |##|  |
+--+--+--+--+
|  |##|  |##|
|  |##|  |##|
+--+--+--+--+
|##|  |##|  |
|##|  |##|  |
+--+--+--+--+

Python 2, 79

N=3*input()+1
for i in range(N):print('+||- #- #+||-# -# '*N)[3**i%7/2%3:3*N:3]

For each row, selects one of the patterns

+--+--+--+--+--+
|  |##|  |##|  |
|##|  |##|  |##|

and prints 3*n+1 characters from it. The pattern is chosen by repeating its first 6 characters, selected with the string interleaving trick, which also serves to extract a snippet of the correct length.

The correct pattern is selected based the value of the row index i modulo 6 by an arithmetic expression 3**i%7/2%3 that gives the repeating pattern [0,1,1,0,2,2]. I found it using the fact that x**i%7 has period 6, then trying different values of x and different postprocessing to get the right pattern.


CJam, 43 42 bytes

ri3*)_2m*{_3f%:!2b\3f/:+2%(e|"#|-+ "=}%/N*

Try it online.

Each coordinate is mapped to a char, e.g. the top left corner is (0, 0) -> "+". Specifically, we calculate

[(y%3 == 0)*2 + (x%3 == 0)] or [(x//3 + y//3) % 2 - 1]

and index into the string "#|-+ " accordingly.