[Question]
  [
Who doesn't love a good fractal? The [Sierpinski Carpet](http://en.wikipedia.org/wiki/Sierpinski_carpet) is a classic example of a fractal.
To complete this task, you will be required to generate a carpet of type \$n\$ and print the resulting image to the `stdout` (see example below for formatting) \$n\$, representing the level carpet. Steps can be found on this [Wikipedia](http://en.wikipedia.org/wiki/Sierpinski_carpet) article.
This value will be taken from `stdin` or equivalent.
For example, an input of 4 would produce a level 4 carpet:
```
‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ†
‚ñ†   ‚ñ† ‚ñ†   ‚ñ† ‚ñ†   ‚ñ† ‚ñ†   ‚ñ† ‚ñ†   ‚ñ† ‚ñ†   ‚ñ† ‚ñ†   ‚ñ† ‚ñ†   ‚ñ† ‚ñ†   ‚ñ†
‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ†
‚ñ† ‚ñ† ‚ñ†       ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ†       ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ†       ‚ñ† ‚ñ† ‚ñ†
‚ñ†   ‚ñ†       ‚ñ†   ‚ñ† ‚ñ†   ‚ñ†       ‚ñ†   ‚ñ† ‚ñ†   ‚ñ†       ‚ñ†   ‚ñ†
‚ñ† ‚ñ† ‚ñ†       ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ†       ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ†       ‚ñ† ‚ñ† ‚ñ† 
‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ†
‚ñ†   ‚ñ† ‚ñ†   ‚ñ† ‚ñ†   ‚ñ† ‚ñ†   ‚ñ† ‚ñ†   ‚ñ† ‚ñ†   ‚ñ† ‚ñ†   ‚ñ† ‚ñ†   ‚ñ† ‚ñ†   ‚ñ†
‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ†
‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ†                   ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ†
‚ñ†   ‚ñ† ‚ñ†   ‚ñ† ‚ñ†   ‚ñ†                   ‚ñ†   ‚ñ† ‚ñ†   ‚ñ† ‚ñ†   ‚ñ†
‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ†                   ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ†
‚ñ† ‚ñ† ‚ñ†       ‚ñ† ‚ñ† ‚ñ†                   ‚ñ† ‚ñ† ‚ñ†       ‚ñ† ‚ñ† ‚ñ†
‚ñ†   ‚ñ†       ‚ñ†   ‚ñ†                   ‚ñ†   ‚ñ†       ‚ñ†   ‚ñ†
‚ñ† ‚ñ† ‚ñ†       ‚ñ† ‚ñ† ‚ñ†                   ‚ñ† ‚ñ† ‚ñ†       ‚ñ† ‚ñ† ‚ñ† 
‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ†                   ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ†
‚ñ†   ‚ñ† ‚ñ†   ‚ñ† ‚ñ†   ‚ñ†                   ‚ñ†   ‚ñ† ‚ñ†   ‚ñ† ‚ñ†   ‚ñ†
‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ†                   ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† 
‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ†
‚ñ†   ‚ñ† ‚ñ†   ‚ñ† ‚ñ†   ‚ñ† ‚ñ†   ‚ñ† ‚ñ†   ‚ñ† ‚ñ†   ‚ñ† ‚ñ†   ‚ñ† ‚ñ†   ‚ñ† ‚ñ†   ‚ñ†
‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ†
‚ñ† ‚ñ† ‚ñ†       ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ†       ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ†       ‚ñ† ‚ñ† ‚ñ†
‚ñ†   ‚ñ†       ‚ñ†   ‚ñ† ‚ñ†   ‚ñ†       ‚ñ†   ‚ñ† ‚ñ†   ‚ñ†       ‚ñ†   ‚ñ†
‚ñ† ‚ñ† ‚ñ†       ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ†       ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ†       ‚ñ† ‚ñ† ‚ñ† 
‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ†
‚ñ†   ‚ñ† ‚ñ†   ‚ñ† ‚ñ†   ‚ñ† ‚ñ†   ‚ñ† ‚ñ†   ‚ñ† ‚ñ†   ‚ñ† ‚ñ†   ‚ñ† ‚ñ†   ‚ñ† ‚ñ†   ‚ñ†
‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ†
```
An input of 3 would produce a level 3 carpet:
```
‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ†
‚ñ†   ‚ñ† ‚ñ†   ‚ñ† ‚ñ†   ‚ñ†
‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ†
‚ñ† ‚ñ† ‚ñ†       ‚ñ† ‚ñ† ‚ñ†
‚ñ†   ‚ñ†       ‚ñ†   ‚ñ†
‚ñ† ‚ñ† ‚ñ†       ‚ñ† ‚ñ† ‚ñ†
‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ†
‚ñ†   ‚ñ† ‚ñ†   ‚ñ† ‚ñ†   ‚ñ†
‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ†
```
An input of 2 would produce a level 2 carpet:
```
‚ñ† ‚ñ† ‚ñ†
‚ñ†   ‚ñ† 
‚ñ† ‚ñ† ‚ñ†
```
And a input of 1 would produce a level 1 carpet (just a square):
```
‚ñ†
```
Note the spaces between the columns.
The idea is to use the ‚ñ† character for blocks and space for gaps
The line starts with the ‚ñ† character.
As always, the smallest solution wins by character count (due to non-standard characters).
Alternatively, # can be used instead of the ‚ñ† character in languages that do not support Unicode.
  
[Answer]
## CJam, ~~38~~ ~~37~~ ~~31~~ ~~30~~ 28 characters
Oh well, we're counting by characters, so let's do some Unicode unpacking:
```
"BËÉ∑ÎßãÌíΩÂ∑ìÎ±ñ·Æ®„£ôÓ≤π¬¨‰ôß‡©•Â¢±Î•ãÏ≤≠"2G#b129b:c~
```
[Test it here.](http://cjam.aditsu.net/) Just put the desired level into the input field.
### Explanation
After base conversion, this is
```
3li(#,{3b1f&2b}%_f{f{&S9632c?S}N}
```
which is the same as the following, just with the Unicode character written as `9632c`:
```
3li(#,{3b1f&2b}%_f{f{&S'‚ñ†?S}N}
```
This code is based on the following observation: if we look at the coordinates *(x,y)* of each cell, then we get an empty cell, whenever both *x* and *y* have a `1` at the same position in their base-3 representation. If you think about it, the small-scale repeating pattern is the significant base-3 digit, then the next more significant digit governs the next larger-scale repetition and so on.
```
3                                      "Push a 3 on the stack.";
 li(                                   "Read input, convert to integer, decrement.";
    #                                  "Raise to that power. This yields the dimensions.";
     ,                                 "Turn into a range array.";
      {       }%                       "Map the block onto the array.";
       3b                              "Convert to base 3.";
         1f&                           "Bit-wise AND each digit with 1.";
            2b                         "Convert to base 2.";
                _                      "Duplicate this list.";
                 f{          }         "Map this block onto one list, with the second list
                                        as an additional parameter.";
                   f{      }           "Map this block onto the second list, with the first
                                        list's current element as an additional parameter.";
                                       "I.e. this iterates over all coordinate pairs.";
                     &                 "Bitwise AND to check that the base-3 representations
                                        had a 1 in the same position.";
                      S'‚ñ†?             "Select the right character.";
                          S            "Push a space.";
                            N          "Push a newline";
```
The contents of the resulting array are printed automatically.
Thanks to Dennis for shaving off three bytes.
[Answer]
# Matlab (113)(110)(99)(85)
You can try it [here](http://lavica.fesb.hr/octave/octave-on-line_en.php) (You'll have to replace `input('')` with your desired input.)
Now 99 thanks to feersum! And now down to 85 thanks to RTL!
Golfed: 
```
a=ones(3);a(5)=0;c=1;for i=2:input('');c=kron(c,a);end;disp(char(kron(c,[1,0])*3+32))
```
Ungolfed:
```
a=ones(3);a(5)=0;c=1;  %creating the template / anchor
for i=2:input('');
    c=kron(c,a);       %recursive iterations
end;
disp(char(kron(c,[1,0])*3+32))
```
```
d=[c,c]*0;  %this is all just for adding the additional spaces
d(:,1:2:end)=c;
disp(char(d*3+32));    %converting to spaces (32) and # (35)
```
Explanation:
I am abusing the kronecker product for this task. (It is a special product defined for two each arbitrary sized matrices. Example:
```
A = [1,2] is a 3x2 matrix, B is a nxm matrix.
    [3,4]
    [5,6]
```
Then 
```
kron(A,B) = [1*B , 2*B] is a 2n x 2m matrix.
            [3*B , 4*B]
            [5*B , 6*B]
```
So heres an example for n=5 (In the old counting method it's 4);
```
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # 
#   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # 
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # 
# # #       # # # # # #       # # # # # #       # # # # # #       # # # # # #       # # # # # #       # # # # # #       # # # # # #       # # # # # #       # # # 
#   #       #   # #   #       #   # #   #       #   # #   #       #   # #   #       #   # #   #       #   # #   #       #   # #   #       #   # #   #       #   # 
# # #       # # # # # #       # # # # # #       # # # # # #       # # # # # #       # # # # # #       # # # # # #       # # # # # #       # # # # # #       # # # 
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # 
#   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # 
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # 
# # # # # # # # #                   # # # # # # # # # # # # # # # # # #                   # # # # # # # # # # # # # # # # # #                   # # # # # # # # # 
#   # #   # #   #                   #   # #   # #   # #   # #   # #   #                   #   # #   # #   # #   # #   # #   #                   #   # #   # #   # 
# # # # # # # # #                   # # # # # # # # # # # # # # # # # #                   # # # # # # # # # # # # # # # # # #                   # # # # # # # # # 
# # #       # # #                   # # #       # # # # # #       # # #                   # # #       # # # # # #       # # #                   # # #       # # # 
#   #       #   #                   #   #       #   # #   #       #   #                   #   #       #   # #   #       #   #                   #   #       #   # 
# # #       # # #                   # # #       # # # # # #       # # #                   # # #       # # # # # #       # # #                   # # #       # # # 
# # # # # # # # #                   # # # # # # # # # # # # # # # # # #                   # # # # # # # # # # # # # # # # # #                   # # # # # # # # # 
#   # #   # #   #                   #   # #   # #   # #   # #   # #   #                   #   # #   # #   # #   # #   # #   #                   #   # #   # #   # 
# # # # # # # # #                   # # # # # # # # # # # # # # # # # #                   # # # # # # # # # # # # # # # # # #                   # # # # # # # # # 
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # 
#   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # 
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # 
# # #       # # # # # #       # # # # # #       # # # # # #       # # # # # #       # # # # # #       # # # # # #       # # # # # #       # # # # # #       # # # 
#   #       #   # #   #       #   # #   #       #   # #   #       #   # #   #       #   # #   #       #   # #   #       #   # #   #       #   # #   #       #   # 
# # #       # # # # # #       # # # # # #       # # # # # #       # # # # # #       # # # # # #       # # # # # #       # # # # # #       # # # # # #       # # # 
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # 
#   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # 
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # 
# # # # # # # # # # # # # # # # # # # # # # # # # # #                                                       # # # # # # # # # # # # # # # # # # # # # # # # # # # 
#   # #   # #   # #   # #   # #   # #   # #   # #   #                                                       #   # #   # #   # #   # #   # #   # #   # #   # #   # 
# # # # # # # # # # # # # # # # # # # # # # # # # # #                                                       # # # # # # # # # # # # # # # # # # # # # # # # # # # 
# # #       # # # # # #       # # # # # #       # # #                                                       # # #       # # # # # #       # # # # # #       # # # 
#   #       #   # #   #       #   # #   #       #   #                                                       #   #       #   # #   #       #   # #   #       #   # 
# # #       # # # # # #       # # # # # #       # # #                                                       # # #       # # # # # #       # # # # # #       # # # 
# # # # # # # # # # # # # # # # # # # # # # # # # # #                                                       # # # # # # # # # # # # # # # # # # # # # # # # # # # 
#   # #   # #   # #   # #   # #   # #   # #   # #   #                                                       #   # #   # #   # #   # #   # #   # #   # #   # #   # 
# # # # # # # # # # # # # # # # # # # # # # # # # # #                                                       # # # # # # # # # # # # # # # # # # # # # # # # # # # 
# # # # # # # # #                   # # # # # # # # #                                                       # # # # # # # # #                   # # # # # # # # # 
#   # #   # #   #                   #   # #   # #   #                                                       #   # #   # #   #                   #   # #   # #   # 
# # # # # # # # #                   # # # # # # # # #                                                       # # # # # # # # #                   # # # # # # # # # 
# # #       # # #                   # # #       # # #                                                       # # #       # # #                   # # #       # # # 
#   #       #   #                   #   #       #   #                                                       #   #       #   #                   #   #       #   # 
# # #       # # #                   # # #       # # #                                                       # # #       # # #                   # # #       # # # 
# # # # # # # # #                   # # # # # # # # #                                                       # # # # # # # # #                   # # # # # # # # # 
#   # #   # #   #                   #   # #   # #   #                                                       #   # #   # #   #                   #   # #   # #   # 
# # # # # # # # #                   # # # # # # # # #                                                       # # # # # # # # #                   # # # # # # # # # 
# # # # # # # # # # # # # # # # # # # # # # # # # # #                                                       # # # # # # # # # # # # # # # # # # # # # # # # # # # 
#   # #   # #   # #   # #   # #   # #   # #   # #   #                                                       #   # #   # #   # #   # #   # #   # #   # #   # #   # 
# # # # # # # # # # # # # # # # # # # # # # # # # # #                                                       # # # # # # # # # # # # # # # # # # # # # # # # # # # 
# # #       # # # # # #       # # # # # #       # # #                                                       # # #       # # # # # #       # # # # # #       # # # 
#   #       #   # #   #       #   # #   #       #   #                                                       #   #       #   # #   #       #   # #   #       #   # 
# # #       # # # # # #       # # # # # #       # # #                                                       # # #       # # # # # #       # # # # # #       # # # 
# # # # # # # # # # # # # # # # # # # # # # # # # # #                                                       # # # # # # # # # # # # # # # # # # # # # # # # # # # 
#   # #   # #   # #   # #   # #   # #   # #   # #   #                                                       #   # #   # #   # #   # #   # #   # #   # #   # #   # 
# # # # # # # # # # # # # # # # # # # # # # # # # # #                                                       # # # # # # # # # # # # # # # # # # # # # # # # # # # 
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # 
#   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # 
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # 
# # #       # # # # # #       # # # # # #       # # # # # #       # # # # # #       # # # # # #       # # # # # #       # # # # # #       # # # # # #       # # # 
#   #       #   # #   #       #   # #   #       #   # #   #       #   # #   #       #   # #   #       #   # #   #       #   # #   #       #   # #   #       #   # 
# # #       # # # # # #       # # # # # #       # # # # # #       # # # # # #       # # # # # #       # # # # # #       # # # # # #       # # # # # #       # # # 
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # 
#   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # 
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # 
# # # # # # # # #                   # # # # # # # # # # # # # # # # # #                   # # # # # # # # # # # # # # # # # #                   # # # # # # # # # 
#   # #   # #   #                   #   # #   # #   # #   # #   # #   #                   #   # #   # #   # #   # #   # #   #                   #   # #   # #   # 
# # # # # # # # #                   # # # # # # # # # # # # # # # # # #                   # # # # # # # # # # # # # # # # # #                   # # # # # # # # # 
# # #       # # #                   # # #       # # # # # #       # # #                   # # #       # # # # # #       # # #                   # # #       # # # 
#   #       #   #                   #   #       #   # #   #       #   #                   #   #       #   # #   #       #   #                   #   #       #   # 
# # #       # # #                   # # #       # # # # # #       # # #                   # # #       # # # # # #       # # #                   # # #       # # # 
# # # # # # # # #                   # # # # # # # # # # # # # # # # # #                   # # # # # # # # # # # # # # # # # #                   # # # # # # # # # 
#   # #   # #   #                   #   # #   # #   # #   # #   # #   #                   #   # #   # #   # #   # #   # #   #                   #   # #   # #   # 
# # # # # # # # #                   # # # # # # # # # # # # # # # # # #                   # # # # # # # # # # # # # # # # # #                   # # # # # # # # # 
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # 
#   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # 
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # 
# # #       # # # # # #       # # # # # #       # # # # # #       # # # # # #       # # # # # #       # # # # # #       # # # # # #       # # # # # #       # # # 
#   #       #   # #   #       #   # #   #       #   # #   #       #   # #   #       #   # #   #       #   # #   #       #   # #   #       #   # #   #       #   # 
# # #       # # # # # #       # # # # # #       # # # # # #       # # # # # #       # # # # # #       # # # # # #       # # # # # #       # # # # # #       # # # 
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # 
#   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # #   # 
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # 
```
[Answer]
# Haskell, ~~114~~ 108
```
s 1=["# "]
s n=k j++k(map(>>" ")j)++k j where j=s$n-1;k i=j%i%j
(%)=zipWith(++)
main=interact$unlines.s.read
```
[Answer]
# Perl 5: 68 characters
*n* on stdin.
```
#!/usr/bin/perl -l
//,print map/2/?"  ":"‚ñ† ",map$_+$',@,for@,=grep!/[24-9]/,0..3x<>/10
```
A decimal coded ternary representation of the list of coordinates is first generated in `@,` (name chosen so there is no need for space between `@,` and `for`) using digits 0, 1, and 3. Now adding x and y coordinates in the decimal domain will have a 2 in the result if and only if there were two ones at matching positions. `//` is used to propagate the default variable `$_` from the outer loop (`for`) to the postmatch variable `$'` when it is shadowed by the default `map` variable in the inner loop.
[Answer]
# Python ‚Äì 100
```
r=range(3**~-input())
for i in r:print" ".join("# "[any(i/3**k%3==j/3**k%3==1for k in r)]for j in r)
```
[Answer]
# Racket ~~230~~ ~~229~~ ~~225~~ 220
Not Racket's finest hour for golfing.
Golfed:
```
(define(s n)(letrec([t(Œª(x y)(if(or(= x 0)(= y 0))"‚ñ†"(if(=(modulo x 3)(modulo y 3)1)" "(t(floor(/ x 3))(floor(/ y 3))))))][i(expt 3(- n 1))])(for-each displayln(for/list([r i])(string-join(for/list([c i])(t r c))" ")))))
```
Ungolfed:
```
(define (s n)
  (letrec ([t (Œª (x y)
                (if (or (= x 0) (= y 0)) 
                    "‚ñ†"
                    (if (= (modulo x 3) (modulo y 3) 1)
                        " "
                        (t (floor (/ x 3)) (floor (/ y 3))))))]
           [i (expt 3 (- n 1))])
    (for-each displayln 
              (for/list ([r i])
                (string-join 
                 (for/list ([c i]) 
                   (t r c)) " ")))))
```
[Answer]
# C: 123 118 111 104 characters
Based on a similar idea as my perl solution.
After adding some spaces:
```
m=0x55555555;
x;
main(n){
  scanf("%d",&n);
  n=1<<2*--n;
  for(x=n*n;x--;)
    printf(x&x/2&m?"":"%c%c",x&x/n&m?32:35,x&n-1?32:10);
}
```
Uses ternary system coding each digit with 2 bits. Illegal values (having two ones in odd-even position) are filtered with `x & (x>>1) & 0b01010101`. Both coordinates are stored in one value, so checking the pixel color is down to `x & (x >> 2 * n) & 0b01010101`. `n` is stored as a power of 2 for convenience.
## Edit
Replaced `define` with a simple constant `m`.
## Edit 2
`0x5555555` mask can be represented with `(1LL<<32)/3`, but we only need `n` of those bits so `n/3` is sufficient.
```
x;
main(n){
  scanf("%d",&n);
  n=1<<2*--n;
  for(x=n*n;x--;)
    printf(x&x/2&n*n/3?"":"%c%c",x&x/n&n/3?32:35,x&n-1?32:10);
}
```
## Edit 3
Minor tweaks. One 2 char gain relying on scanf being executed before the loading value of `n` for the execution of `--n`.
The eol can only follow `#`, duh.
```
x;
main(n){
  n=scanf("%d",&n)<<2*--n;
  for(x=n*n;x--;)
    x&x/2&n*n/3||printf(x&x/n&n/3?"  ":x&n-1?"# ":"#\n");
}
```
[Answer]
# Mathematica, 71 bytes
```
Grid@Nest[ArrayFlatten@ArrayPad[{{0}},1,{{#}}]&,1,#]/.{0->"",1->"‚ñ†"}&
```
**input**
> 
> 3
> 
> 
> 
**output**
[![enter image description here](https://i.stack.imgur.com/uiOLy.jpg)](https://i.stack.imgur.com/uiOLy.jpg)
[Answer]
# HTML/JavaScript, 205 Chars
## [Obfuscatweet](http://xem.github.io/obfuscatweet/), 205 Chars
```
document.write(unescape(escape('üÅ≥®±≤™ë∞≠Äæ¨∞Ωô∞¶´°¢¨±∞û∞ßû±Æüê¥û±≠üëç®ë¥™ÄÆ¨ÅØ≠∞®ú∞¨´†≠úê©û±¶´±≤öÅ©üê∞û±©üÅ≠û±©ö∞´õÅ§öÄßüÅ¢¨†æô∞©öëª©°Ø¨†®™†ΩúÄª™†º´êªöë©©†®®∞®™ê¨™†´ö∞©öë§öÄßò∞ßöêª©ë¨¨±•òÅ§öÅ≥öëΩ©°µ´°£≠Å©´±ÆòÅ£öÅ∏õÅπöëª≠±®™ë¨©ê®ÆÅºØÅπöëª™ë¶öÅ∏ôê≥üêΩúê¶ô°πôê≥üêΩúê©¨°•≠Åµ¨°ÆòÄ∞û±∏üë¶öÅ∏öêªÆêΩ©†®Æê©Øë≤©ë¥≠ë≤´††úëΩ©°µ´°£≠Å©´±ÆòÅ¶öÅ°öëª¨°•≠Åµ¨°ÆòÅç®ë¥™ÄÆ©°¨´±Ø¨†®®êØú∞©Øë¶≠ëÆ®±¥™ëØ´††©Ä®®ê©Æ±§´±£≠ë≠©ëÆ≠ÄÆ≠±≤™ë¥©ê®¨∞´®ê©Øêºõ±≥®±≤™ë∞≠ÄæüÅ≥≠Åπ´Å•ü†™Æ±¶´±Æ≠Ä≠©°°´ë©´Åπû†¢†±Ø≠ë≤™ë•¨†¢').replace(/uD./g,'')))
```
## HTML/JS, 298 Chars
Due to how HTML plays with whitespace, a few characters had to be dedicated to the nbsp char. In addition, the default font of most browsers is not Courier, so I had to set it to that, too. About 20 characters worth of styling. If this requires a direct input method, I can add it, but changing the input currently is setting n to a different value.
[Demo](http://c99.nl/f/114334.html)
```
<script>s='&nbsp;';n=4;m=Math.pow(3,n-1);for(i=0;i<m;i++,d('<br>')){for(j=0;j<m;)if(c(i,j++))d('#');else d(s)}function c(x,y){while(x||y){if(x%3==1&&y%3==1)return 0;x=f(x);y=f(y)}return 1}function f(a){return Math.floor(a/3)}function d(a){document.write(s+a)}</script><style>*{font-family:"Courier"
```
## Readable HTML/JS
```
<script>
    s='&nbsp;';
    n=4;
    m=Math.pow(3,n-1);
    for(i=0;i<m;i++,d('<br>')){
        for(j=0;j<m;)
            if(c(i,j++))
                d('#');
            else d(s)
    }
    function c(x,y){
        while(x||y){
            if(x%3==1&&y%3==1)
                return 0;
            x=f(x);
            y=f(y)
        }
        return 1
    }
    function f(a){
        return Math.floor(a/3)
    }
    function d(a){
        document.write(s+a)
        }
</script>
<style>
*{font-family:"Courier"
```
[Answer]
# CJam, ~~38~~ ~~35~~ ~~32~~ 31 characters
```
"‚ñ† ""’õ‡≠ó‰ÅéÓúºÎΩîÌúºÍÜ©Èó≥‚æø‚û∫‚•ßÊß≤„©°ÈÉä"6e4b128b:c~
```
[Try it online.](http://cjam.aditsu.net/ "CJam interpreter")
### Example run
```
$ cjam <(echo '"‚ñ† ""’õ‡≠ó‰ÅéÓúºÎΩîÌúºÍÜ©Èó≥‚æø‚û∫‚•ßÊß≤„©°ÈÉä"6e4b128b:c~') <<< 3; echo
‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† 
‚ñ†   ‚ñ† ‚ñ†   ‚ñ† ‚ñ†   ‚ñ† 
‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† 
‚ñ† ‚ñ† ‚ñ†       ‚ñ† ‚ñ† ‚ñ† 
‚ñ†   ‚ñ†       ‚ñ†   ‚ñ† 
‚ñ† ‚ñ† ‚ñ†       ‚ñ† ‚ñ† ‚ñ† 
‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† 
‚ñ†   ‚ñ† ‚ñ†   ‚ñ† ‚ñ†   ‚ñ† 
‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† 
```
### How it works
```
"’õ‡≠ó‰ÅéÓúºÎΩîÌúºÍÜ©Èó≥‚æø‚û∫‚•ßÊß≤„©°ÈÉä"6e4b128b:c~
```
converts the Unicode string from base 60,000 (`6e4b`) to base 128 (`128b`), casts to Character (`:c`) and evaluates the resulting string (`~`).
As a result, the following code gets executed:
```
"‚ñ† "                                " C := '‚ñ† '                                           ";
    li(                             " J := int(input()) - 1                               ";
       {                      }*    " for I in range(J):                                  ";
        z]A*                        "   T := [zip(C)] * 10                                ";
            ):,                     "   U := pop(T)                                       ";
               Sf*                  "   V := [ ' ' * len(u) : u ‚àä U ]                     ";
                  4\t               "   U[4] := V                                         ";
                     3/{:+z~}%      "   C := { c : c ‚àä zip(concat(u)), u ‚àä U.split(3) }   ";
                              zN*  " print '\n'.join(zip(C))                              ";
```
[Answer]
# Python 3 ‚Äì ~~116~~ 113 characters
**EDIT:** Well, used the trick I don't like too much myself and compressed the code by 3 bytes. Dunno if that's the best possible way, but I'll go with it.
```
exec(bytes('‚±¥„µ¨‚ùõÈõ¢‚Ç†Â¥ßÊ∞¨Êµ°Êë¢‚Å°„©∫Áô•Ê±°Á®®‚ú´‚Å´ÊΩ¶‚Å≤‚Å´Êπ©Áê†‚ùù‡®©ÊΩ¶‚Å≤‚Å©Êπ©Áà†Êπ°ÊïßÊ§®ÁëÆÊ§®ÁÅÆÁëµ‚§®‚¥©‚§±Áà∫ÁÄ¨Ê∞Ω‚ú®„çõ‚ú™‚∞©‚°¨Â¨¢‚≠´‚Äß‚ú†‚†™‚®≥Ê§™‚¨©‚§¢ÁêªÁàΩÁÄ´Áà´ÊòäÁâØÊ§†Ê§†‚ÅÆ„©¥Áâ∞Êπ©‚°¥‚•©','utf-16')[2:].decode('utf-8'))
```
It may contain some unprintable characters, so here's a printable version of the string.
```
'‚±¥„µ¨‚ùõÈõ¢‚Ç†Â¥ßÊ∞¨Êµ°Êë¢\u2061„©∫Áô•Ê±°Á®®‚ú´\u206bÊΩ¶\u2072\u206bÊπ©Áê†‚ùù\u0a29ÊΩ¶\u2072\u2069Êπ©Áà†Êπ°ÊïßÊ§®ÁëÆÊ§®ÁÅÆÁëµ‚§®\u2d29‚§±Áà∫ÁÄ¨Ê∞Ω‚ú®„çõ‚ú™‚∞©‚°¨Â¨¢\u2b6b‚Äß‚ú†‚†™‚®≥Ê§™‚¨©‚§¢ÁêªÁàΩÁÄ´Áà´ÊòäÁâØÊ§†Ê§†\u206e„©¥Áâ∞Êπ©‚°¥‚•©'
```
Not too great, but at least beats some languages.
What it expands to:
```
t=['‚ñ† ']
for i in range(int(input())-1):r,p=[k*3for k in t],[k+'  '*(3**i)+k for k in t];t=r+p+r
for i in t:print(i)
```
Somewhat ungolfed in case someone can't see how it works:
```
t=['‚ñ† ']                                     # iteration 1
for i in range(int(input()) - 1):            # do n-1 more iterations
    r = [k * 3 for k in t]                   # first & last rows are the last carpet x3
    p = [k + '  ' * (3 ** i) + k for k in t] # middle row: last carpet, space, last carpet
    t = r + p + r                            # and put them to the new carpet
for i in t:                                  # print final iteration
    print(i)
```
[Answer]
## CJam, 76 characters
```
3ri(#:M_*,{_M/:I\M%:J;;{I3%1=J3%1=&0X?:X;I3/:I0>J3/:J0>|}gX'‚ñ†S?1:X;}%M/Sf*N*
```
This is a direct translation of the formula given [here](http://en.wikipedia.org/wiki/Sierpinski_carpet)
[Try it here](http://cjam.aditsu.net/)
[Answer]
# Bash+coreutils, 105 unicode characters
Since we're counting characters and not bytes:
```
eval `iconv -tunicode<<<ÊΩ¶‚°≤Áú®„åΩ‚®™‚ê®‚¥±‚§±Áê¨„ÄΩÁêªÁúºÁú™Áêª‚¨´‚§©Á¨ªÊà†ÓàΩÍÇñÊòªÁâØ‚†®„µ∏‚ï¥‚±∑„µπ‚Ω¥„≠∑„π∏Á∞∞Á•º„ÄæÁ†ª„¥Ø‚∞≥‚Ωπ„åΩ‚§©Á¨ª‚††Á†®„å•„Ñ≠Á±º‚ïπ‚¥≥‚§±Á∞©ÊâºÂ∞ΩÁ∞†Á°º„ÄΩÁ¥ªÁÄªÊ•≤ÁëÆ‚Å¶‚ê¢‚Å¢„¨¢‚†®‚ï¥‚µ∑‚≠∑‚§±Á∞©ÊïºÊ°£„≠Ø‡©Ω|cut -b3-`
```
---
In its decoded form:
# Pure Bash, 143 bytes
```
for((w=3**($1-1),t=0;t<w*w;t++));{
b=‚ñ†
for((x=t%w,y=t/w;x>0||y>0;x/=3,y/=3));{
((x%3-1||y%3-1))||b=\ ||x=0
}
printf "$b "
((t%w-w+1))||echo
}
```
Input is taken from command-line args:
### Output:
```
$ ./sierpinskicarpet.sh 3
‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† 
‚ñ†   ‚ñ† ‚ñ†   ‚ñ† ‚ñ†   ‚ñ† 
‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† 
‚ñ† ‚ñ† ‚ñ†       ‚ñ† ‚ñ† ‚ñ† 
‚ñ†   ‚ñ†       ‚ñ†   ‚ñ† 
‚ñ† ‚ñ† ‚ñ†       ‚ñ† ‚ñ† ‚ñ† 
‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† 
‚ñ†   ‚ñ† ‚ñ†   ‚ñ† ‚ñ†   ‚ñ† 
‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† ‚ñ† 
$ 
```
[Answer]
# C - 154
Input from stdin. I tried to find a good way to avoid an extra function, but couldn't come up with any.
The character count includes only necessary spaces.
```
p(l,x,y){
    return l?x/l&y/l&1||p(l/3,x%l,y%l):0;
}
x,y;
main(v){
    scanf("%d",&v);
    v=pow(3,--v);
    for(;y<v;y++,puts(""))
        for(x=0;x<v;)
            printf("%c ",p(v,x++,y)?32:35);
}
```
[Answer]
# [Python 2](https://docs.python.org/2/), 91 bytes
```
r=input()-1
for i in range(3**r):x,s='# ','  ';exec"x+=[x,s][i%3%2]+x;s*=3;i/=3;"*r;print x
```
[Try it online!](https://tio.run/##DchBDkUwEADQvVNMiJQiQq00PYlYiPR/sxnNqGScvmze4oUnHieNKbFDCnes6m7IficDAhLwRn9fGa25nqW9nCpAtQpAWS9@z6Vxy9frgqUpx7URe2lnLPYfuWYbGCmCpDS9 "Python 2 ‚Äì Try It Online")
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 17 [bytes](https://github.com/DennisMitchell/jelly/wiki/Code-page)
```
‚Äô3*·∏∂b3·∏Ç·∏Ñ&√æ`¬¨·ªã‚Åæ# G
```
**[Try it online!](https://tio.run/##ASoA1f9qZWxsef//4oCZMyrhuLZiM@G4guG4hCbDvmDCrOG7i@KBviMgR////zQ "Jelly ‚Äì Try It Online")**
### How?
```
‚Äô3*·∏∂b3·∏Ç·∏Ñ&√æ`¬¨·ªã‚Åæ# G - Link: integer, n
‚Äô                 - decrement -> n-1
 3*               - three raised to (that)
   ·∏∂              - lowered range -> [0,1,...,3^(n-1)-1]
    b3            - convert to base three (vectorises)
      ·∏Ç           - least significant bit (vectorises) -> i.e. make 2 trits become 0s
       ·∏Ñ          - convert from base two (vectorises)
          `       - use that as both arguments of:
         √æ        -   outer product with:
        &         -     bitwise AND
           ¬¨      - logical NOT (vectorises)
            ·ªã     - index into:
             ‚Åæ#   -   list of characters ['#', ' ']
                G - format as a grid
```
[Answer]
# oK, ~~40~~ 45 bytes
```
`0:" "/'" #"{(x-1)(,'//3 3#111101111b*9#,)/1}
```
[Try it online.](http://johnearnest.github.io/ok/?run=%20%600%3A%22%20%22%2F%27%22%20%23%22%7B%28x-1%29%28%2C%27%2F%2F3%203%23111101111b%2a9%23%2C%29%2F1%7D4%3B)
It starts with `1`, and then draws it in a grid `(1 1 1;1 0 1;1 1 1)`, which it then draws in a grid the same way, etc. repeated the necessary number of times.
[Answer]
# [Haskell](https://www.haskell.org/), 77 characters
```
f n|a<-mapM(:[0,1])[2..n]=[do x<-a;"‚ñ† "!!(0^product(zipWith(+)x y)):" "|y<-a]
```
[Try it online!](https://tio.run/##y0gszk7Nyfn/P00hrybRRjc3scBXwyraQMcwVjPaSE8vL9Y2OiVfocJGN9Fa6dG0BQpKiooaBnEFRfkppcklGlWZBeGZJRka2poVCpWamlZKCko1lUC1sf9zEzPzbEGmKRSUlgSXFPnkKagopCmY/AcA "Haskell ‚Äì Try It Online")
[Answer]
# PHP, 194 characters
The `n` received as first argument in command line.
```
<?php
function d(&$a,$n,$e,$x,$y){if(--$n)for(;$i<9;)$p=pow(3,$n)|d($a,$n,$e|$i==4,$x+$p*$j,$y+$p*($i-$j)/3)|$j=++$i%3;else$a[$x][$y]=$e?" ":‚ñ†;}@d($a,$argv[1]);foreach($a as$s)echo join($s),"
";
```
## Readable
```
<?php
function draw(&$array, $n, $empty, $x, $y) {
    $n--;
    if ($n != 0) {
        for ($i = 0; $i < 9; $i++) {
            $j = $i % 3;
            $p = pow(3, $n);
            draw($array, $n, $empty || $i == 4, $x + $p * $j, $y + $p * ($i - $j) / 3);
        }
    } else {
        $array[$x][$y] = $empty ? " " : "#";
    }
}
$array = array();
draw($array, $argv[1], false, 0, 0);
foreach ($array as $line) {
    echo join($line), "\n";
}
```
[Answer]
**Scala 230 characters**
Golfed code:
```
object T extends App {def m=math.pow(3,args(0).toInt-1).toInt-1;def p=print _;val x=0 to m;x.map{n=>x.map{j=>if(q(n,j)==1)p(" #");else p("  ")};p("\n");};def q(n:Int,j:Int):Int={if(n>0|j>0)if((n%3&j%3)==1)0 else q(n/3,j/3)else 1}}
```
Ungolfed code:
```
object T extends App {
  def m = math.pow(3, args(0).toInt - 1).toInt - 1;
  def p = print _;
  val x = 0 to m;
  x.map { n => x.map { j => if (q(n, j) == 1) p(" #"); else p("  ")}; p("\n");};
  def q(n: Int, j: Int): Int = {
    if (n > 0 | j > 0) if ((n % 3 & j % 3) == 1) 0 else q(n / 3, j / 3) else 1
  }
}
```
Only necessary spaces are included.
[Answer]
# [SOGL V0.12](https://github.com/dzaima/SOGL), 27 [bytes](https://github.com/dzaima/SOGL/blob/master/chartable.md)
```
 ‚ñ†¬π.H{¬≥¬≥‚îº‚îº‚â•: ‚ñ†@≈ó;‚îº‚îº‚Å¥++}{@‚àëP
```
[Try it Here!](https://dzaima.github.io/SOGLOnline/?code=JTIwJXUyNUEwJUI5LkglN0IlQjMlQjMldTI1M0MldTI1M0MldTIyNjUlM0ElMjAldTI1QTBAJXUwMTU3JTNCJXUyNTNDJXUyNTNDJXUyMDc0KyslN0QlN0JAJXUyMjExUA__,inputs=NA__)
[Answer]
# [C# (.NET Core)](https://www.microsoft.com/net/core/platform), 162 bytes
```
n=>{var f="";int s=(int)Math.Pow(3,n),z=0;while(z<s*s){int x=z%s,y=z/s,h=1;for(;x>0|y>0;y/=3,x/=3)if(y%3==1&x%3==1)h=0;f+=" #"[h]+(z++%s<s-1?" ":"\n");}return f;}
```
[Try it online!](https://tio.run/##NY@5TsQwFEXr8VdYRkE2ySxRqHAcCiQqRhqJggIoLGMTS8FBfs5MFvLtwcPSvFu8o6t7FKxV6/XSgXXv@HGAoD84Uo0EwIcJQZDBKnzfOVVaFzIIPnIVNl6qIBss8OJENR2lx0YQwiODQdAYbC9DvTm0J1pkjmWj2PFTbRtNxxKugE1nshdjAtkgxi1ktci5aT3lfbX7GqodH7aiyPp4mDV0SAoh8sv@J1gdy0wqCL4gz/VrSsc0TaCEdX5LMLkhL44wPnsdOu@w4fPC0b/IsbVveC@towxNaHXeraT/1CGa/DnRa8bR6q510DZ68@Rt0A/WafrLxd@M5uUb "C# (.NET Core) ‚Äì Try It Online")
### Degolfed
```
n=>{
    var f="";
    int s=(int)Math.Pow(3,n),z=0;
    while(z<s*s)
    {
        int x=z%s, y=z/s, h=1;
        for(; x>0 | y>0; y/=3, x/=3)
            if(y%3==1 & x%3==1)
                h=0;
        f += " #"[h] + (z++%s<s-1? " " : "\n");
    }
    return f;
}
```
[Answer]
## [Canvas](https://github.com/dzaima/Canvas), ~~17~~ ~~16~~ 17 characters
```
‚ñ†Ôºõ‚ï∑Ôºª‚åê ÔºãÔºí√óÔºõ‚îå‚àî‚àîÔºõÔºìÔºäÔºã
```
[Try it here!](https://dzaima.github.io/Canvas/?u=JXUyNUEwJXVGRjFCJXUyNTc3JXVGRjNCJXUyMzEwJTIwJXVGRjBCJXVGRjEyJUQ3JXVGRjFCJXUyNTBDJXUyMjE0JXUyMjE0JXVGRjFCJXVGRjEzJXVGRjBBJXVGRjBC,i=Mw__)
-1: *Used `Ôºª` instead of `ÔΩõ` to delete the first `Ôºõ` inside the loop.*  
+1: *Fixed errenous behavior: `‚ñ†` now corresponds to level 1, as specified in the original post.*
[Answer]
# [Pip](https://github.com/dloscutoff/pip) `-S`, 30 characters
```
"‚ñ†‚ñ† "@MX{{aTB3R2i}MSg}MC3**a/3
```
[Try it online!](https://tio.run/##K8gs@P9f6dG0BUCkoOTgG1FdnRjiZBxklFnrG5xe6@tsrKWVqG/8//9/3eD/JgA "Pip ‚Äì Try It Online")
The basic idea: consider a coordinate grid in base 3. The holes in the carpet occur where 1) a trit in the x-coordinate is `1`, and 2) the trit in the same position in the y-coordinate is also `1`.
```
"‚ñ†‚ñ† "@MX{{aTB3R2i}MSg}MC3**a/3
                                i is 0; a is 1st cmdline arg (implicit)
                        3**a/3  Width/height of the carpet
                      MC        Make a coordinate grid that size and map this function
                                to the coordinate pairs:
                    g            Take each [x y] pair
                  MS             Map this function to each coord and add the results:
         {aTB3   }                Convert to base 3
              R2i                 Replace 2's with 0's
                                  E.g. 15 -> 120 -> 100 and 16 -> 121 -> 101
                                 When we add the results, we get [15 16] -> 201
      MX{            }           Take the max of that list (0, 1, or 2)
"‚ñ†‚ñ† "@                           Use that to index into this string (resulting in a space
                                 iff two 1's coincided to make a 2, or ‚ñ† otherwise)
                                Print the resulting nested list with each sublist on its
                                own line and space-delimited (implicit, -S flag)
```
Similar solution, same number of characters but -2 bytes: `{2N({aTB3R2i}MSg)?s'‚ñ†}MC3**a/3`
[Answer]
# [K (ngn/k)](https://bitbucket.org/ngn/k), ~~50~~ 49 bytes
thanks @DLosc for reminding me I should output spaces between the columns
thanks @coltim for -1 byte
```
1@"\n"/("# "1_,/1,'+/')'a*/:\:a:+2!!1_(. 0:"")#3;
```
[Try it online!](https://tio.run/##y9bNS8/7/9/QQSkmT0lfQ0lZQckwXkffUEddW19dUz1RS98qxirRSttIUdEwXkNPwcBKSUlT2dj6/38TAA "K (ngn/k) ‚Äì Try It Online")
[Answer]
# [Vyxal](https://github.com/Vyxal/Vyxal), 19 bytes
```
‚Äõ #3?‚Äπe Å3œÑ‚à∑vB:v‚ãè‚Ä†ƒ∞‚Åã
```
[Try it Online!](https://vyxal.pythonanywhere.com/#WyIiLCIiLCLigJsgIzM/4oC5ZcqBM8+E4oi3dkI6duKLj+KAoMSw4oGLIiwiIiwiNCJd)
## How?
```
‚Äõ #3?‚Äπe Å3œÑ‚à∑vB:v‚ãè‚Ä†ƒ∞‚Åã
    ?‚Äπ              # Push input - 1
   3  e             # Push 3 to the power of it
        Å            # Get range [0, that)
        3œÑ          # Convert each to base 3 (ternary)
          ‚à∑         # Modulo each by two to convert twos to zeros
           vB       # Convert each from binary to integers
             :v‚ãè    # Outer product bitwise AND with itself
                ‚Ä†   # Logical NOT for each
‚Äõ #              ƒ∞  # Index each into " #"
                  ‚Åã # Join each by spaces, and then join on newlines
```
[Answer]
# [R](https://www.r-project.org/), 92 characters
94 bytes with the special character.
```
write(c(" ","‚ñ†")[1+Reduce("%x%",rep(list(matrix(c(1,1,1,1,0,1),3,3)),n<-scan()-1),1)],1,3^n)
```
[Try it online!](https://tio.run/##K/r/v7wosyRVI1lDSUFJR@nRtAVKmtGG2kGpKaXJqRpKqhWqSjpFqQUaOZnFJRq5iSVFmRVAtYY6EGigY6ipY6xjrKmpk2ejW5ycmKehqQsUMtSMBcoax@Vp/jf8DwA "R ‚Äì Try It Online")
[Answer]
# [Husk](https://github.com/barbuz/Husk), 27 bytes
```
mJ' ¬¥·π™»Ø!"‚ñ° "¬¨nm·∏ã‚Ä†%2mB3≈Ä`^3‚Üê
```
[Try it online!](https://tio.run/##ATMAzP9odXNr//9tSicgwrThuarIryEi4pahICLCrG5t4biL4oCgJTJtQjPFgGBeM@KGkP///zU "Husk ‚Äì Try It Online")
Translation of Jonathan Allan's program.
uses the '‚ñ°' character.
[Answer]
# [J](http://jsoftware.com/), 35 50 bytes
```
' #'{~1|:@}.[:,/0,:"1]9&([:,/_3,./\0"+4}(#,:)),:@1
```
[Try it online!](https://tio.run/##JY7BasJAGITveYohAdfguibaS5cKQaGn0kOxJxUJ8U@zEndld0MNbfrqMdrDwAx8M8ypDwUrsZRg4EggB00F1h9vrz1DxH7@0l@ZdWIr@SzhMkz3z6PxPRwWXMx2STh56sYRl3HMZZb2cfC@EliZKznkljTzuOTWw5Rwpm68MtrBNP7SePFANxW1zBJOjfPwBkeq1VkNtiLk2n2TdShqym3d/hc@3TCdTJU@0lXpLxEEVFQGXOAlK8PJcD/FHIv@Bg "J ‚Äì Try It Online")
*+15 thanks to DLosc for pointing out there had to be spaces between columns.*
This was a quick fix to satisfy the spec and could likely be re-golfed further.
## [J](http://jsoftware.com/), original answer, cleaner, 35 bytes
```
' #'{~]9&([:,/_3,./\0"+4}(#,:)),:@1
```
[Try it online!](https://tio.run/##JY5BCwFBHMXv@yleq4zNGMu6mChRTnIQJ6SN/9rRmtHMbEh89bVxePUOv/frXapQsAxjCQaOGLJOR2C2WswrhgZ7ffbDZmsrefeQcNHdxWF78G41uIwiLie9KgqWU4GpeZBDakkzj1tqPUwGZ4rSK6MdTOlvpRc/dJ3Tk1nCpXQe3uBEhbqquuaEVLs7WYdjQaktnv/BxtXquKP0iR5Kn0UQ0DE34AKjSRa267899JFUXw "J ‚Äì Try It Online")
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), 21 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage)
```
‚Äû# 3I<m√ù¬®3Œ¥–≤√âJCDŒ¥&ƒÄ√®¬ª
```
Port of [*@JonathanAllan*'s Jelly answer](https://codegolf.stackexchange.com/a/205210/52210), so make sure to upvote him as well!
[Try it online](https://tio.run/##ASsA1P9vc2FiaWX//@KAniMgM0k8bcOdwqgzzrTQssOJSkNEzrQmxIDDqMK7//80) or [verify all test cases](https://tio.run/##yy9OTMpM/W/iquSZV1BaYqWgZO@nw6XkX1oC5en8f9QwT1nB2M8m9/DcQyuMz225sOlwp5ezy7ktakcaDq84tPu/zqFt9v8B).
**Explanation:**
```
    I<                # Push the input-1
   3  m               # Take 3 to the power this input-1
       √ù              # Pop and push a list in the range [0,3**(input-1)]
        ¬®             # Remove the last item to lower the range to: [0,3**(input-1))
          Œ¥           # Map over each integer:
         3 –≤          #  Convert it to a base-3 list
            √â         # Check for each trigit if it's odd, converting the 2s to 0s
             J        # Join the inner bit-lists together to strings
              C       # Convert each from a binary-string to an integer
               D      # Using a copy of itself,
                Œ¥     # apply double-vectorized over this list of integer:
                 &    #  Bitwise-AND the integers together
                  ƒÄ   # Check for each integer whether it's NOT 0 (0 if 0; 1 otherwise)
‚Äû#                 √®  # 0-based index it into the string "# "
                    ¬ª # Join each inner list by spaces, and then each string by newlines
                      # (after which the result is output implicitly)
```
]