# #OctothorpeAsciiArt

An Octothorpe, (also called number sign, hash or hashtag, or pound sign) is the following ASCII character:

#


Isn't that a fun shape? Lets make bigger versions of it! So here is your challenge:

Given a positive integer N, output an ASCII hashtag of size N.

For example, an ASCII hashtag of size 1 looks like this:

 # #
#####
# #
#####
# #


Trailing whitespace on each line is allowed, but not required.

The input will always be a valid positive integer, so you don't have to handle non-numbers, negative, or 0. Your output can be in any reasonable format, so outputting to STDOUT, returning a list of strings, or string with newlines, a 2D matrix of characters, writing to a file, etc. are all fine.

## Test cases

2:
##  ##
##  ##
##########
##########
##  ##
##  ##
##########
##########
##  ##
##  ##

3:
###   ###
###   ###
###   ###
###############
###############
###############
###   ###
###   ###
###   ###
###############
###############
###############
###   ###
###   ###
###   ###

4:
####    ####
####    ####
####    ####
####    ####
####################
####################
####################
####################
####    ####
####    ####
####    ####
####    ####
####################
####################
####################
####################
####    ####
####    ####
####    ####
####    ####

5:
#####     #####
#####     #####
#####     #####
#####     #####
#####     #####
#########################
#########################
#########################
#########################
#########################
#####     #####
#####     #####
#####     #####
#####     #####
#####     #####
#########################
#########################
#########################
#########################
#########################
#####     #####
#####     #####
#####     #####
#####     #####
#####     #####


Since this is a code-golf, try to write the shortest possible solution you can, and above all else, have fun!

• Related – pppery Aug 17 '17 at 21:38

# MATL, 201612 11 bytes

3 bytes thanks to DJMcMayhem.

1 byte thanks to Luis Mendo.

21BwY"&*~Zc


Try it online!

## Explanation

    % stack starts with input e.g. 2
21  % push 21 to stack             2 21
B   % convert to binary            2 [1 0 1 0 1]
w   % swap                         [1 0 1 0 1] 2
Y"  % repeat                       [1 1 0 0 1 1 0 0 1 1]
&*  % one-input multiplication    [[1 1 0 0 1 1 0 0 1 1]
[1 1 0 0 1 1 0 0 1 1]
[0 0 0 0 0 0 0 0 0 0]
[0 0 0 0 0 0 0 0 0 0]
[1 1 0 0 1 1 0 0 1 1]
[1 1 0 0 1 1 0 0 1 1]
[0 0 0 0 0 0 0 0 0 0]
[0 0 0 0 0 0 0 0 0 0]
[1 1 0 0 1 1 0 0 1 1]
[1 1 0 0 1 1 0 0 1 1]]
~   % complement                  [[0 0 1 1 0 0 1 1 0 0]
[0 0 1 1 0 0 1 1 0 0]
[1 1 1 1 1 1 1 1 1 1]
[1 1 1 1 1 1 1 1 1 1]
[0 0 1 1 0 0 1 1 0 0]
[0 0 1 1 0 0 1 1 0 0]
[1 1 1 1 1 1 1 1 1 1]
[1 1 1 1 1 1 1 1 1 1]
[0 0 1 1 0 0 1 1 0 0]
[0 0 1 1 0 0 1 1 0 0]]
Zc  % convert 0 to spaces            ##  ##
1 to octothorpes               ##  ##
and join by newline          ##########
##########
##  ##
##  ##
##########
##########
##  ##
##  ##

• You can use Zc instead of 35*c and ~ (logical NOT) instead of 0= – James Aug 17 '17 at 20:12
• @DJMcMayhem @_@ why is that a built-in – Leaky Nun Aug 17 '17 at 20:13
• Actually, the reason that's a builtin is really interesting. I could be wrong, but I think conor suggested it, and Suever wrote a script that looks at all the MATL answers to see what functions are more common for future improvements. Zc was just added – James Aug 17 '17 at 20:15
• Also, since each cell just has to be non-zero, you could do Q instead of 2< – James Aug 17 '17 at 20:18
• @LeakyNun You can change !t* to &*. The latter means "one-input multiplication", which multiplies (element-wise) the input by its transpose – Luis Mendo Aug 18 '17 at 1:50

# Brain-Flak, 420 bytes

(()()()){({}<(({})){({}<<>(<>({})<>){({}<((((()()()()){}){}()){}())>[(
)])}{}(<>({})<>){({}<((((()()()()){}){}){})>[()])}{}(<>({})<>){({}<(((
(()()()()){}){}()){}())>[()])}{}(<>({})<>){({}<((((()()()()){}){}){})>
[()])}{}((()()()()()){})<>>[()])}{}((({}))<(({})(({}){}){})>){({}<<>(<
>({})<>){({}<((((()()()()){}){}()){}())>[()])}{}((()()()()()){})<>>[()
])}{}{}>[()])}{}({}<>)(({})((({({})({}[()])}{})){}){}{}){({}<{}>[()])}


Try it online!

No, the score of 420 was not intentional. I promise. Readable version:

# 3 Times...
(()()())
{
({}<

#Duplicate the input
(({}))

#Input times...
{
({}<

#Switch to the main stack
<>

#Grab the duplicate of the input
(<>({})<>)

#That many times...
{({}<

# Push a hash
((((()()()()){}){}()){}())

>[()])}{}

#Grab the duplicate of the input
(<>({})<>)

#That many times...
{({}<

#Push a space
((((()()()()){}){}){})

>[()])}{}

#Grab the duplicate of the input
(<>({})<>)

#That many times...
{({}<

# Push a hash
((((()()()()){}){}()){}())

>[()])}{}

#Grab the duplicate of the input
(<>({})<>)

#That many times...
{({}<

#Push a space
((((()()()()){}){}){})

>[()])}{}

#Push a newline
((()()()()()){})

#Toggle back to the alternate stack
<>

#Decrement the (second) loop counter
>[()])

#Endwhile
}

#Pop the now zeroed loop counter
{}

#Turn [a] into [a, a*5, a]
((({}))<(({})(({}){}){})>)

#A times....
{
({}<

#Toggle back over
<>

#Grab a*5
(<>({})<>)

#That many times...
{({}<

#Push a space
((((()()()()){}){}()){}())

>[()])}{}

#Push a newline
((()()()()()){})

#Toggle back
<>

#Decrement the (second) loop counter
>[()])

}

#Pop the loop counter and the a*5
{}{}

#Decrement the outer loop counter
>[()])
}

#Pop the zeroed loop counter
{}

#Pop a over
({}<>)

#Pushes (a**2) * 5 + a
(({})((({({})({}[()])}{})){}){}{})

#That many times...
{({}<

#Pop a character off the output stack
{}

>[()])}


# 6502 machine code (C64), 59 56 bytes

00 C0 20 9B B7 A9 06 85 FC 86 FE A6 FE 86 FD A9 03 4D 1F C0 8D 1F C0 C6 FC D0
01 60 A9 23 A0 05 49 00 20 D2 FF CA D0 FA A6 FE 88 D0 F3 A9 0D 20 D2 FF C6 FD
D0 E6 F0 D3


### Online demo

Usage: SYS49152,N where N is a number between 1 and 255.

(values greater than 4 will already be too large for the C64 screen, starting from 8, the output is even too wide)

Explanation:

         00 C0       .WORD $C000 ; load address .C:c000 20 9B B7 JSR$B79B      ; read N into X
.C:c003  A9 06       LDA #$06 ; number of "logical" lines plus 1 for hash .C:c005 85 FC STA$FC        ; store in counter variable for lines
.C:c007  86 FE       STX $FE ; store N in counter variable for char repetitions .C:c009 A6 FE LDX$FE        ; load repetition counter
.C:c00b  86 FD       STX $FD ; store in counter variable for line repetitions .C:c00d A9 03 LDA #$03       ; value to toggle the character toggle
.C:c00f  4D 1F C0    EOR $C01F ; xor character bit toggle .C:c012 8D 1F C0 STA$C01F      ; store character bit toggle
.C:c015  C6 FC       DEC $FC ; decrement "logical" lines .C:c017 D0 01 BNE$C01A      ; not 0 -> continue
.C:c019  60          RTS            ; program done
.C:c01a  A9 23       LDA #$23 ; load hash character .C:c01c A0 05 LDY #$05       ; load "logical" columns for hash
.C:c01e  49 00       EOR #$00 ; in each odd "logical" line, toggle character .C:c020 20 D2 FF JSR$FFD2      ; output one character
.C:c023  CA          DEX            ; decrement character repetition
.C:c024  D0 FA       BNE $C020 ; not 0 -> back to output .C:c026 A6 FE LDX$FE        ; reload character repetition
.C:c028  88          DEY            ; decrement "logical" columns
.C:c029  D0 F3       BNE $C01E ; not 0 -> back to character toggle .C:c02b A9 0D LDA #$0D       ; line done, load newline character
.C:c02d  20 D2 FF    JSR $FFD2 ; and output .C:c030 C6 FD DEC$FD        ; decrement line repetitions
.C:c032  D0 E6       BNE $C01A ; not 0 -> back to character init .C:c034 F0 D3 BEQ$C009      ; else back to main loop (toggle char toggling)


• +1 for nostalgia (6502 assembly on a c64 was my first programming experience...) – Olivier Dulac Aug 18 '17 at 14:01

l%n=l!!1:l++l<*[1..n]
f n=["##"%n,"# "%n]%n


Try it online!

Outputs a list of strings.

# Python 2, 55 bytes

def f(n):p=[(" "*n+"#"*n)*2]*n;print(p+["#"*n*5]*n)*2+p


Try it online!

This returns a 2D list of characters.

# Python 2, 65 bytes

def f(n):p=((" "*n+"#"*n)*2+"\n")*n;print(p+("#"*n*5+"\n")*n)*2+p


Try it online!

# Python 2, 66 bytes

def f(n):p=[(" "*n+"#"*n)*2]*n;print'\n'.join((p+["#"*n*5]*n)*2+p)


Try it online!

• Wat witchkraft is yer footer – Leaky Nun Aug 17 '17 at 20:25
• @LeakyNun A for loop :) – Mr. Xcoder Aug 17 '17 at 20:25
• No, I'm talking about the f(i); storing the result in a temp and print accessing it. – Leaky Nun Aug 17 '17 at 20:26
• @LeakyNun Ya misunderstood: f(i) prints and print in Python 2 adds a newline :P – Mr. Xcoder Aug 17 '17 at 20:27
• Oh, how stupid of me. – Leaky Nun Aug 17 '17 at 20:30

# Charcoal, 21 bytes

ＮθＵＯ×²θ#ＵＯθ Ｆ²⟲ＯＯ²⁴⁶θ


Try it online! Link is to verbose version of code. I'd originally tried a cute bitmap approach:

Ｆ⁵Ｆ⁵Ｆ＆｜ικ¹«Ｊ×ιＩθ×κＩθＵＯθ#


Try it online! Link is to verbose version of code. Explanation: Works by considering the # as an array of 5×5 squares. The squares that are in odd rows or columns need to be filled in.

• does charcoal really not have a hashtag shape built-in? – dzaima Aug 17 '17 at 20:58
• Did I tie charcoal O_O? – Magic Octopus Urn Aug 17 '17 at 21:06
• yay (hmm looks like I need to fix that a bit) – ASCII-only Aug 17 '17 at 21:23
• @ASCII-only What needs fixing? – Neil Aug 17 '17 at 21:32
• Oblong shouldn't be printing the steps for the polygon it uses internally lol – ASCII-only Aug 17 '17 at 21:33

# J, 22 bytes

#('# '{~#:5$21,0)#~"1]  Try it online! A lot of similarity to the other J answer, though I don't understand trains with lots of nouns well, so my answer has three potential bytes to cut off (two parens and a reflexive-~). # Explanation ### Generating the octothorpe The octothorpe is made by everything in the parenthetical, reproduced below for convenience. '# '{~#:5$21,0


A lot of the way I make the octothorpe is abuse of the way that J pads its arrays when they aren't long enough.

21,0 simply creates the array 21 0.

# CJam, 2726 25 bytes

{_[{S3*'#*'#5*}3*;]fe*e*}


Try it online!

Fun fact: This originally started at 29 bytes, and bytes have been removed one-by-one ever since, alternating between block and full-program mode.

## Explanation:

{                          e# Stack:               | 2
_                         e# Duplicate:           | 2 2
[                        e# Begin array:         | 2 2 [
{                       e# Do the following 3 times:
S                      e#   Push a space       | 2 2 [" "
3*                    e#   Repeat it 3 times: | 2 2 ["   "
'#*                 e#   Join with '#':     | 2 2 [" # # "
'#               e#   Push '#':          | 2 2 [" # # " '#
5*             e#   Repeat it 5 times: | 2 2 [" # # " "#####"
}3*          e# End:                 | 2 2 [" # # " "#####" " # # " "#####" " # # " "#####"
;         e# Delete top of stack: | 2 2 [" # # " "#####" " # # " "#####" " # # "
]        e# End array:           | 2 2 [" # # " "#####" " # # " "#####" " # # "]
fe*     e# Repeat characters:   | 2 ["  ##  ##  " "##########" "  ##  ##  " "##########" "  ##  ##  "]
e*   e# Repeat strings:      | ["  ##  ##  " "  ##  ##  " "##########" "##########" "  ##  ##  " "  ##  ##  " "##########" "##########" "  ##  ##  " "  ##  ##  "]
}  e# End
e# Result:
e# ["  ##  ##  "
e#  "  ##  ##  "
e#  "##########"
e#  "##########"
e#  "  ##  ##  "
e#  "  ##  ##  "
e#  "##########"
e#  "##########"
e#  "  ##  ##  "
e#  "  ##  ##  "]

• Someone was prepared for this challenge :P – ETHproductions Aug 17 '17 at 20:10
• @ETHproductions It was a CMC and moved to main... – Esolanging Fruit Aug 17 '17 at 20:10
• @ETHproductions Can't really blame him for that... – Leaky Nun Aug 17 '17 at 20:12

## Husk, 12 10 bytes

´Ṫ▲Ṙ" # #


Try it online! Note the trailing space.

## Explanation

´Ṫ▲Ṙ" # #   Implicit input, e.g. n=2.
Ṙ" # #   Repeat each character of the string n times: "  ##  ##  "
´Ṫ          Outer product with itself by
▲         maximum: ["  ##  ##  ","  ##  ##  ","##########","##########","  ##  ##  ","  ##  ##  ","##########","##########","  ##  ##  ","  ##  ##  "]
Print implicitly, separated by newlines.


# J, 23 19 bytes

' #'{~1=]+./~@#i:@2


Saved 4 bytes thanks to @LeakyNun.

Try it online!

## Explanation

' #'{~1=]+./~@#i:@2  Input: integer n
2  The constant 2
i:@   Range [-2, -1, 0, 1, 2]
]            Get n
#      Copy each n times
+./~@       GCD table
1=             Equals 1, forms the hashtag for input 1
' #'{~               Index and select the char

• Rats! Was just about to post a (4 byte longer) solution of my own. I'm really impressed by how you're able to compose these functions without caps and with few conjunctions. – cole Aug 17 '17 at 20:57
• @cole Thanks. Sometimes caps can be avoided by using a noun and dyad. For example, [:|:f could be 0|:f – miles Aug 17 '17 at 21:14
• ' # '{~]#"1]#+./~@i:@2 saves a byte – Conor O'Brien Aug 18 '17 at 0:45
• repeat before multiplication gives you 19 bytes: f=:' #'{~1=]+./~@#i:@2 – Leaky Nun Aug 18 '17 at 3:57
• @hoosierEE It's a new feature coming in J 8.06. You can try the beta jsoftware.com/download/j806/install – miles Aug 18 '17 at 22:55

# Jelly, 1413 11 bytes

Saved 2 bytes thanks to @JonathanAllen

5ẋ€Ẏ&þị⁾ #


A monadic link returning a list of lines. Note the trailing space.

Try it online!

### How it works

5ẋ€Ẏ&þị⁾ #    Main link. Arguments: n (integer)            1
5              Yield 5.
ẋ€            Create a range and repeat each item n times. [[1], [2], [3], [4], [5]]
Ẏ           Tighten; dump all sublists into the main list.
[1, 2, 3, 4, 5]
þ         Create a table of                            [[1, 0, 1, 0, 1],
&          bitwise ANDs,                                 [0, 2, 2, 0, 0],
        reusing this list.                            [1, 2, 3, 0, 1],
[0, 0, 0, 4, 4],
[1, 0, 1, 4, 5]]
ị⁾ #    Index into the string " #".                   [" # # ",
0 -> "#", 1 -> " ", 2 -> "#", etc.             "#####",
" # # ",
"#####",
" # # "]

• Nice observation regarding bitwise or - save two bytes by switching from or to and - removing the need to lower, allowing an implicit range and removing the need for µ (or the ⁸ you could have had there instead)... 5ẋ€Ẏ&þị⁾ # – Jonathan Allan Aug 17 '17 at 23:04
• @JonathanAllan Interesting--why does 5Ḷẋ€ require the µ, but not 5ẋ€? – ETHproductions Aug 17 '17 at 23:26
• I thought the need was just to stop Ẏ acting on n and then passing it to the right of ẋ€, since with a nilad-dyad leading chain being called monadically it's not necessary. I'm not quite sure, however, how  seems to then place 5 (or maybe the list of that length) on the right of the tabled & though. – Jonathan Allan Aug 18 '17 at 1:04

# Game Maker Language, 138 108 bytes

n=argument0 s=''for(j=0;j<5*n;j+=1){for(l=0;l<5*n;l+=1)if(j div n|l div n)&1s+='#'else s+=' 's+='
'}return s


Intended as a script (Game Maker's name for user-defined functions), thus the n=argument0 and return s. 20 bytes could be shaved by taking n directly from the current instance and using s as the result. (The instance gets these variables anyway because they weren't declared with var).

Beware of course that # is used by Game Maker's graphics stuff as an alternative newline character, so you might want to prefix it with \ if you want to output to the screen ;)

Also note that I'm using Game Maker 8.0's version of GML here; modern GML versions might have features that could save additional bytes.

Some ideas courtesy of friends wareya and chordbug.

• I think this is the first GML answer i've ever seen – Timothy Groote Aug 18 '17 at 14:32
• @TimothyGroote It's a shame it isn't used more, its optional brackets and semicolons are great for golfing :) – Andrea Aug 18 '17 at 14:33

# Perl 5, 49 + 1 (-p) = 50 bytes

$_=' # # '=~s/./$&x$_/gre x$_;$_.=(y/ /#/r.$_)x2


Try it online!

How?

Implicitly store the input in $_ via the -p flag. Start with the most basic possible top line " # # " with its trailing newline. Replicate each of those characters by the input number. Then replicate that by the input number to form the top part of the octothorpe, storing all of that back in$. Then append the line with all characters replaced by '#' times the input number. Then append the top section. Do those last two sentences a total of two times. Output of the $is implicit in the -p flag. • I like how your answer is just as readable as mine. – AdmBorkBork Aug 17 '17 at 20:31 • They've always said that Perl is a write-only language. – Xcali Aug 17 '17 at 20:41 # 05AB1E, 2522 21 bytes •LQ•bûε×}5ôεS„# èJ¹F=  Try it online! -1 because Emigna hates transliterate and, thankfully, reminds me I should too :P. Gotta be a better way than bitmapping it... Still working. • Reflection... is not the answer in 05AB1E, though it seems like it could be... – Magic Octopus Urn Aug 17 '17 at 20:53 • 5ôεS„# èJ¹F= saves a byte. – Emigna Aug 17 '17 at 20:56 • @Emigna would canvas be good for this? – Magic Octopus Urn Aug 17 '17 at 20:59 • Possibly. I haven't tried the canvas yet so I'm not really sure of its capabilities. Seems like something it's made for. – Emigna Aug 17 '17 at 21:00 ## JavaScript (ES6), 79 bytes f= n=>[...Array(n*5)].map((_,i,a)=>a.map((_,j)=> #[(i/n|j/n)&1]).join).join  <input type=number oninput=o.textContent=f(this.value)><pre id=o> Port of the bitmap approach that I'd used for my original Charcoal attempt. # Python 2, 124, 116, 113, 112, 98, 96 66 bytes New (Credit: HyperNeutrino): def f(a):i='print(" "*a+"#"*a)*2;'*a;exec(i+'print"#"*a*5;'*a)*2+i  Old: a=input();b,c="# " for i in"012": exec'print c*a+b*a+c*a+b*a;'*a if i<"2":exec'print b*a*5;'*a  Try it online! Obviously not the shortest solution, but I think it's decent. Any feedback would be appreciated! • a,b,c=input()," #" should save some bytes. – James Aug 17 '17 at 23:33 • @DJMcMayhem That gave me an error. Did you mean a,b,c=input(),"#"," "? Which isn't any shorter...I appreciate the help! – Braeden Smith Aug 17 '17 at 23:41 • Oh, sorry. I assumed that worked because a,b="# " works. – James Aug 17 '17 at 23:44 • a=input();b,c="# " will work and save bytes – Ad Hoc Garf Hunter Aug 17 '17 at 23:44 • You can also get get rid of the parens in (i==2) and add a space to the beginning. – Ad Hoc Garf Hunter Aug 17 '17 at 23:47 # Brain-Flak, 338 332 bytes 6 bytes thanks to Riley. (({}<>)<(())>)(()()()()()){({}<(<>)<>{({}<<>({}<(((((()()()()())){})){}{}{})<>([({})]()){(<{}({}<((((({}))){}){}{}){({}<<>(({}))<>>[()])}{}>)>)}{}(({})<{{}(<(()()()()()){({}<<>(<([{}](((((()()){}){}){}){}()){}())>)<>{({}<<>({}<(({}))>())<>>[()])}<>({}<>{})>[()])}{}>)}>{})<>((()()()()()){})>())<>>[()])}<>({}<>{}<([{}]())>)>[()])}<>  Try it online! ## More "readable" version (({}<>)<(())>)(()()()()()) {({}<(<>)<>{({}<<>({}<(((((()()()()())){})){}{}{})<> ([({})]()){(<{}({}< ((((({}))){}){}{}){({}<<>(({}))<>>[()])}{} >)>)}{}(({})<{{}(< (()()()()()){({}<<>(<([{}](((((()()){}){}){}){}()){}())>)<>{({}<<>({}<(({}))>())<>>[()])}<>({}<>{})>[()])}{} >)}>{}) <>((()()()()()){})>())<>>[()])}<>({}<>{}<([{}]())>)>[()])}<>  Try it online! • (({})<>)(())<>({}<>) at the beginning can be replaced with (({}<>)<(())>) – Riley Aug 18 '17 at 13:46 # SOGL (SOGLOnline commit 2940dbe), 15 bytes ø─Ζ┘Χ⁴‘5n{.∙.*T  To run this, download this and run the code in the index.html file. Uses that at that commit (and before it) * repeated each character, not the whole string. Explanation: ø─Ζ┘Χ⁴‘ push " # # ##### # # ##### # # " 5n split into lines of length 5 { for each line do .∙ multiply vertically input times .* multiply horizontally input times T output in a new line  Bonus: add 2 inputs for separate X and Y length! • "commit 2940dbe" - I like that idea. Can you explain why ø─Ζ┘Χ⁴‘ pushes that though? – Magic Octopus Urn Aug 17 '17 at 20:54 • @MagicOctopusUrn That's SOGLs compression, which here stores a dictionary of " " and # and the base-2 data required for that string. – dzaima Aug 17 '17 at 21:12 • Neat, is it stable enough for me to start using :)? – Magic Octopus Urn Aug 17 '17 at 21:40 • @MagicOctopusUrn Well it's pretty stable as there have been no answer-breaking changes since SOGLOnline, but whether you can use it (as in understand it) is another question. You can try though and ask question in TNB – dzaima Aug 17 '17 at 21:44 • Haha... Ill wait for documentation then. I do need coddled a little. – Magic Octopus Urn Aug 17 '17 at 21:45 # brainfuck, 224 bytes ,[->+>>>>+<<<<<]>>>+>+++++[-<<<[->+>>>>>+>+++++[-<<<[->+<<<[->>>>>>+<<[->>>+>---<<<<]<<<<]>>>>>>[-<<<<<<+>>>>>>]>[-<<<+>>>]+++++[->+++++++<]>.[-]<<<<<<]>[-<+>]>[-<->]<+[->+<]>>]<<++++++++++.[-]<<<<<]>[-<+>]>[-<->]<+[->+<]>>]  Try it online! ## Making-of I tried to build this code by hand and spent quite a few hours, so I decided to make a transpiler in Python. Here is the code I entered to make this code: read(0) copy(0,(1,1),(5,1)) add(3,1) add(4,5) loop(4) loop(1) add(2,1) add(7,1) add(8,5) loop(8) loop(5) add(6,1) loop(3) add(9,1) loop(7) add(10,1) add(11,-3) end(7) end(3) copy(9,(3,1)) copy(10,(7,1)) add(10,5) copy(10,(11,7)) write(11) clear(11) end(5) copy(6,(5,1)) copy(7,(6,-1)) add(6,1) copy(6,(7,1)) end(8) add(6,10) write(6) clear(6) end(1) copy(2,(1,1)) copy(3,(2,-1)) add(2,1) copy(2,(3,1)) end(4)  Try it online! # C (gcc), 98 93 bytes 5 bytes thanks to Felix Palmen. i,j;main(a){for(scanf("%d",&a);j<a*5||(j=!puts(""),++i<a*5);)putchar(i/a+1&j++/a+1&1?32:35);}  Try it online! # Gaia, 9 bytes  # ”ṫ&:Ṁ‡  Pretty much a port of Zgarb's great answer Try it online! (the footer is just to pretty print, the program itself returns a 2D list of characters) ### Explanation  # ” Push the string " # " ṫ Bounce, giving " # # " & Repeat each character by input : Copy Ṁ‡ Tabled maximum with itself  # Befunge, 105 103 bytes p9p&5*08p>08g- v >,g1+:00p^v0:/5g8_p9g1+:09p08g-#v_@ gvg90\/\g0< # # ##### 0:/5g8,+55< ^>\/2%5*+92++2  Try it online! • Could you add a link to an online interpreter? tio.run/#befunge is a good one AFAIK. – James Aug 18 '17 at 4:54 # Python, 8884 77 bytes lambda x:[[(' #'[i//x%2]+'#')[j//x%2]for j in range(5*x)]for i in range(5*x)]  Try it online! Returns 2D list of characters. # PowerShell, 726863 60 bytes param($a)(,($x=,((' '*$a+"#"*$a)*2)*$a)+,("#"*5*$a)*$a)*2;$x  Try it online! Takes input $a. Then, we do a bunch of magic string and array manipulation.

(,($x=,((' '*$a+"#"*$a)*2)*$a)+,("#"*5*$a)*$a)*2;$x ' '*$a+"#"*$a # Construct a string of spaces and # ( )*2 # Repeat it twice ,( )*$a                       # Repeat that $a times to get the top as an array ($x=                       )                      # Store that into $x and immediately output it , + # Array concatenate that with ... ,("#"*5*$a)          # another string, the middle bar ...
*$a # repeated$a times.
(                                            )*2;   # Do that twice
$x # Output$x again


You can peel off the parts of the explanation starting from the bottom to see how the output is constructed, so hopefully my explanation makes sense.

a#b=a++b++a++b++a
c%l=((c<$l)#('#'<$l))<$l f n=(' '%[1..n])#('#'%[1..n])  Returns a list of strings. Try it online! How it works: a#b=a++b++a++b++a -- concatenate the strings a and b in the given pattern c%l= -- take a char c and a list l (we only use the length -- of l, the actual content doesn't matter) c<$l                   -- make length l copies of c
'#'<$l -- make length l copies of '#' # -- combine them via function # <$l         -- and make length l copies of that string
f n=                       -- main function
#            -- make the "a b a b a" pattern with the strings
-- returned by the calls to function %
' '%[1..n]             --   one time with a space
'#'%[1..n]  --   one time with a '#'


# Mathematica, 63 bytes

ArrayFlatten@Array[x=#;Table[If[OddQ@-##," ","#"],x,x]&,{5,5}]&


### Explanation

ArrayFlatten@Array[x=#;Table[If[OddQ@-##," ","#"],x,x]&,{5,5}]&  (* input N *)

x=#                                           (* Set x to N *)
&          (* A function that takes two inputs: *)
If[OddQ@-##," ","#"]                (* if both inputs are odd (1), " ". "#" otherwise *)
Table[                    ,x,x]           (* Make N x N array of that string *)
Array[                                     ,{5,5}]  (* Make a 5 x 5 array, applying that function to each index *)
ArrayFlatten@                                                    (* Flatten into 2D array *)


(1)-## parses into Times[-1, ##]

• ArrayFlatten is very nice. – Mark S. Aug 20 '17 at 2:48

# Python 2, 113 bytes

As an array of strings:

r=[1-1*(i%(2*n)<n)for i in range(5*n)]
print[''.join(' #'[r[k]+r[j]>0]for k in range(len(r)))for j in range(n*5)]


As ASCII art:

# Python 3, 115 bytes

r=[1-1*(i%(2*n)<n)for i in range(5*n)]
for j in range(n*5):print(*(' #'[r[k]+r[j]>0]for k in range(len(r))),sep='')


# Python 3, 117 bytes

p=range(5*n)
for i,e in enumerate([j%(2*n)>=n for j in p]for k in p):print(*[' #'[i%(2*n)>=n or k]for k in e],sep='')


As an array of booleans

# Python 2, 75 bytes

p=range(5*n)
f=lambda o:o%(2*n)>=n
print[[f(j)or f(i)for j in p]for i in p]


• Long time, no see :-) – ETHproductions Aug 17 '17 at 22:55
• Yes, it has! @ETHproductions – Zach Gates Aug 17 '17 at 23:01

# Java 8, 103 bytes

Lambda accepts Integer and prints the octothorpe to standard out. Cast to Consumer<Integer>.

n->{for(int s=5*n,x=0,y;x<s;x++)for(y=0;y<s;)System.out.print((x/n%2+y++/n%2>0?'#':32)+(y<s?"":"\n"));}


Try It Online

## Ungolfed lambda

n -> {
for (
int
s = 5 * n,
x = 0,
y
;
x < s;
x++
)
for (y = 0; y < s; )
System.out.print(
(x / n % 2 + y++ / n % 2 > 0 ? '#' : 32)
+ (y < s ? "" : "\n")
);
}


The key observation here is that, on a 5 by 5 grid of n by n cells, octothorpes appear wherever the row or column number (0-based) is odd. I'm pretty sure this is the cheapest general approach, but it seems further golfable.

## Acknowledgments

• -1 byte thanks to Kevin Cruijssen
• You can place the int s=5*n,x=0,y instead the for-loop to save a byte on the semicolon. – Kevin Cruijssen Aug 18 '17 at 6:40

# Pyth, 28 22 bytes

-6 bytes thanks to @LeakyNun

JsC*]S5Qjmsm@"# "*kdJJ


Test Suite.

• 22 bytes – Leaky Nun Aug 18 '17 at 13:59
• @LeakyNun Thanks, I didn't really golf this answer so far. – Mr. Xcoder Aug 18 '17 at 14:00

# R, 8785 62 bytes

m=matrix(" ",x<-scan()*5,x);m[s,]=m[,s<-rep(!1:0,e=x/5)]="#";m


2 bytes saved by representing c(F,T) as !1:0, thanks to LeakyNun

23 bytes saved thanks to Giuseppe

Try it online!

Explanation (ungolfed):

x=scan()*5              # Multiply input by 5 to get the required width/height of the matrix
m=matrix(" ",x,x)       # Create a matrix of the required dimensions
s=rep(!1:0,each=x/5)    # The sequence s consists of F repeated n times, followed by T repeated n times
m[s,]="#"               # Use s as logical indices to set those rows as "#" characters.
# R recycles the sequence to the height of the matrix.
m[,s]="#"               # Same, with columns
write(m,"",x,,"")       # Print out across the required number of columns
`