Programming Puzzles & Code Golf Stack Exchange is a question and answer site for programming puzzle enthusiasts and code golfers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need help building a brick wall! Throw together some code for me using no input and produce the following output wall shown below:

_|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|
___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|__
_|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|
___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|__
_|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|
___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|__
_|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|
___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|__
_|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|
___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|__

Now, this wall is exactly 10 characters high and 70 characters wide.

As stated above, no inputs, only code. Least amount of bytes, we have to efficiently build this brick wall. Obviously, this program has to function to get the wall built..? or it obviously won't build itself! Good luck!

Edit: Current lowest byte counts hold at 12 bytes!

(Preferably, include the output or a "Try it Online" button below your answer if you can. Thanks!)

share|improve this question
1  
Related, Related, – Flp.Tkc 2 days ago
6  
Also Related. (odd that this should come up today, haha) – Conor O'Brien 2 days ago
    
This would be around 10 bytes in Crayon, too bad there's no interpreter yet... – ETHproductions 2 days ago
1  
That's OK. I'll let you know when I have a working interpreter. I'm working on it right now, actually :) – ETHproductions 16 hours ago
1  
Related! – Rudolf L. Jelínek 12 hours ago

61 Answers 61

Trumpscript, 303 285 244 231 226 bytes

make i 1000005-1000000
as long as,i;:
make i,i - fact;
say "_|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|"
say "___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|__"!
America is great

I would like to say this is one of the most verbose languages where almost everything fails to compile into a working program.

Apparently whether - works instead of minus is completely up to the interpreter and sometimes works. This time it did so I'm putting it in as golfed.

Abuses the fact Trumpscript is written in Python and therefore fact when used as an integer is one.

Golfing tips welcome.

share|improve this answer
23  
I take it Trumpscript doesn't allow numbers less than 1,000,000? ;-) – ETHproductions 2 days ago
1  
Can you use i is 1000005-1000000 and i is i-fact? (Just taken a look at the readme of Trumpscript.) – AlexRacer 2 days ago
1  
@AlexRacer I'll update once I get to a computer with a Trumpscript interpreter so I can test that – BlueEyedBeast 2 days ago
3  
@Brian if you're running on windows or Mac you have to pass the --shut-up argument – BlueEyedBeast 22 hours ago
2  
I'm surprised it allows you to use 1000000. Documentation states All numbers must be strictly greater than 1 million. The small stuff is inconsequential to us.. – Mad Physicist 10 hours ago

APL, 12 bytes

10 70⍴'_|__'

Output:

      10 70⍴'_|__'
_|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|
___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|__
_|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|
___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|__
_|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|
___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|__
_|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|
___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|__
_|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|
___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|__
share|improve this answer
    
I just noticed this answer as I put my J answer. they're basically the same haha – Conor O'Brien 2 days ago
2  
This outputs something else in addition to the ascii wall. Is this allowed? – TheBitByte yesterday
    
when using tryapl.org, I got the wall output. what have you received @TheBitByte? – dylan 16 hours ago
    
@Dylan He's probably confused, since the answerer included the program in the output without knowing the REPL nature of APL. – Conor O'Brien 10 hours ago

BBC BASIC 29 characters

Tokenised filesize 23 bytes.

WIDTH70P.STRING$(175,"_|__")

WIDTH70 would normally be followed by a newline. It sets the field width to 70. Then we just print 175 copies of the string, which wrap around.

share|improve this answer
1  
Best (ab)use of WIDTH that I have seen :) – ElPedro 2 days ago
    
This should have "23 bytes" in the header then. – Adám 2 days ago

J, 12 bytes

10 70$'_|__'

Shapes the string on the right into a 10 by 70 shape. Simple!

share|improve this answer

WinDbg, 45 bytes

f2000000 L2bc 5f 7c 5f 5f;da/c46 2000000 L2bc

How it works:

f 2000000 L2bc 5f 7c 5f 5f; *Repeat the pattern _|__ (5F 7C 5F 5F) to fill 2BC (700) bytes 
                            *starting at 2000000
da /c46 2000000 L2bc        *Show 2BC (700) ASCII chars starting from 2000000 in lines 
                            *of length 0x46 (70)

Output:

0:000> f2000000 L2bc 5f 7c 5f 5f;da/c46 2000000 L2bc
Filled 0x2bc bytes
02000000  "_|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|"
02000046  "___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|__"
0200008c  "_|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|"
020000d2  "___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|__"
02000118  "_|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|"
0200015e  "___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|__"
020001a4  "_|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|"
020001ea  "___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|__"
02000230  "_|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|"
02000276  "___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|__"
share|improve this answer

Brainfuck, 171 Bytes

+++++[>+++++++++++++++++++<-]+++++++[>>++++++++++++++++++<<-]>>--<<++[>>>+++++<<<-]+++++[>.>.>>+++++++++++++++++[<<<...>.>>-]<.>+++++++++++++++++[<<<...>.>>-]<<<..>>.<<<-]

BrainFuck is fun, here is my submission

Here is the output

_|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|
___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|__
_|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|
___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|__
_|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|
___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|__
_|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|
___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|__
_|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|
___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|__
share|improve this answer

05AB1E, 13 bytes

Code:

"_|__"175×Tä»

Explanation:

"_|__"         # For the string "_|__"
      175×     # Repeat that 175 times
          Tä   # Split into 10 even pieces
            »  # And join them by newlines

Uses the CP-1252 encoding. Try it online!

share|improve this answer

Python 2, 37 bytes

s="_|__"*17;print(s+"_|\n__%s\n"%s)*5

Decomposes two rows as 17 copies of _|__, plus another copy interrupted by a newline, plus 17 more copies, plus another newline.

Longer alternatives:

print"%s_|\n__%s\n"%(2*("_|__"*17,))*5

s="_|__"*17;print"%s_|\n__%%s\n"%s%s*5

for i in[0,2]*5:print("_|__"*18)[i:i+70]

print("_|__"*17+"_|\n"+"___|"*17+"__\n")*5

for s in["_|__","___|"]*5:print(s*18)[:70]

s="_|__"*99;exec"print s[:70];s=s[2:];"*10

print("%s"*70+"\n")*10%(175*tuple("_|__"))
share|improve this answer
    
Your last alternative is shorter as print(("%s"*70+"\n")*10%(175*(*"_|__",))) in Python 3. – mbomb007 2 days ago

PHP, 44 42 41 characters

<?=chunk_split(str_pad(_,700,"|___"),70);

(Just because had no chance to use chunk_split() ever before.)

Thanks to:

  • user59178 for suggesting to use str_pad() (-1 character)

Sample run:

bash-4.3$ php <<< '<?=chunk_split(str_pad(_,700,"|___"),70);'
_|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|
___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|__
_|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|
___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|__
_|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|
___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|__
_|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|
___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|__
_|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|
___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|__
share|improve this answer
    
bytes, not character count. – dylan 2 days ago
2  
Same. I use no multibyte characters. – manatwork 2 days ago
6  
1  
@pajonk, Fixed with PPCG - Crossed Out 44 user style on my machine: i.stack.imgur.com/czn5h.png – manatwork 2 days ago
    
You can save a byte by using str_pad instead of str_repeat, largely because _ is treated as a constant with value _. – user59178 yesterday

Pyth, 12 bytes

Code:

jcT*175"_|__

Explanation:

       "_|__    # For the string "_|__"
   *175         # Repeat it 175 times
 cT             # Chop into 10 equal pieces
j               # Join them by newlines

Try it here.

share|improve this answer

V, 24, 16 bytes

175i_|__ò70|lé

Try it online! This contains <esc> characters (0x1B) so here is a hexdump:

0000000: 3137 3569 5f7c 5f5f 1bf2 3730 7c6c e90a  175i_|__..70|l..

8 bytes indirectly saved thanks to Jordan!

share|improve this answer
    
19 bytes: v.tryitonline.net/… I couldn't figure out how to use the .\{-} shortcut mentioned in the V docs, though. – Jordan 2 days ago
    
@Jordan Wow, very nice! The \{-} shortcut wouldn't work anyway, since you can't change the number inside. However, you could set the high bit on the \{ to get this instead. Feel free to post that as an answer. – DrMcMoylex 2 days ago
    
Ah, that makes sense. Posted here: codegolf.stackexchange.com/a/99070/11261 – Jordan 2 days ago
    
Damn I still need to grok this language: 25 bytes – statox yesterday

V, 18 bytes

-1 byte thanks to DJMcMayhem.

175i_|__<Esc>Ó.û70}/°ò

Here it is with unprintable characters in xxd format:

0000000: 3137 3569 5f7c 5f5f 1bd3 2efb 3730 7d2f  175i_|__....70}/
0000010: b0f2                                     ..

Try it online!

share|improve this answer
    
Nice, I am no longer the only person who has used V! Now I'm going to have to see if I can take the lead back, haha – DrMcMoylex 2 days ago

Perl, 31 bytes

say+($@="_|__"x17,"_|
__$@
")x5

You'll need -E flag to run it :

perl -E 'say+($@="_|__"x17,"_|
__$@
")x5'
share|improve this answer
    
Thought of a slightly different approach for 29 bytes: say for("_|__"x175)=~/.{70}/g :). I do like the trick you employed there though! – Dom Hastings yesterday
    
@DomHastings huhu, I wrote the exact same code in the comments of Gabriel Benamy's answer! – Dada yesterday
    
D'oh! Didn't see that one! Also then saw it's been used a lot in other answers.. Oh well! – Dom Hastings yesterday
    
@DomHastings Yea, I didn't thought of it at first, and it was already in Gabriel's answer, so that's why I didn't update my answer after ;) – Dada yesterday

Perl, 47 34 29 bytes

$_="_|__"x175;say for/.{70}/g
share|improve this answer
    
You can golf it down to 29 : say for("_|__"x175)=~/.{70}/g – Dada 2 days ago
    
For some reason, that used to produce no output every time I tried it, but I found another solution in as many bytes. Thank you though! – Gabriel Benamy 2 days ago
    
Well, the code I suggested does produce a valid output... Maybe you forgot the parenthesis around "_|__"x175 or something like that? – Dada 2 days ago
    
I think that's what it is. I figured parentheses had to go somewhere, I just couldn't figure out where, lol – Gabriel Benamy 2 days ago
    
Huhu, hard to remember the precedence of every operator (=~ has a higher precedence than x)! – Dada 2 days ago

PowerShell v2+, 34 30 bytes

'_|__'*175-split"(.{70})"-ne''

Stupid regex matching algorithm requiring the -ne'' ... wastes five bytes!

'_|__'*175-split"(.{70})"-ne''
'_|__'*175                     # Repeat this string 175 times
          -split"       "      # Split on this regex pattern:
                  .{70}        # Match any character 70 times
                 (     )       # Encapsulated in parens so we keep the regex results
                         -ne'' # But don't select the empty strings
                               # Output with newlines via Write-Output is implicit

Saved 4 bytes thanks to Conor!

share|improve this answer
    
Would .{70} be any shorter for teh regex? – Conor O'Brien 2 days ago
    
split works like that in other languages - you always get the unmatched portions whether you want them or not. Some languages have a match operator that can be used to return an array of only matching results, but I don't see a PowerShell equivalent for that. – Neil yesterday
    
@Neil Performing 'abc'-split'(.)' will return ('','a','','b','','c',''). There's nothing unmatched, but due to how the algorithm processes through the input string, you get empty strings back. See here. – TimmyD yesterday
    
Yes, and I'm saying you shouldn't be surprised by that result, because that's what split's supposed to do. – Neil yesterday
    
@Neil Surprised? No, not really. Doesn't mean I have to be happy about it, though. :D – TimmyD yesterday

MATL, 15 bytes

'_|__'700:)70e!

Of course, you can Try it online! Explanation:

'_|__' % Put a brick on the stack
700    % 700 times
:)     % Makes a happy mason...
70e!   % Secret freemason code

OK, actually, it works as follows:

'_|__' % Put the first bit of the string on the stack
700:   % Put 1, 2, ..., 700 on the stack as array
)      % Index into the string, modularly. Result: '_|___|__ ... __'
70e    % Reshape into 70 rows (and consequently, 10 columns)
!      % Transpose to get the desired output.
share|improve this answer
    
Well done! And your smiley is better than mine – Luis Mendo 2 days ago
    
@LuisMendo Really, using smileys could be considered a design pattern in MATL. xD Perhaps you could have :) on C... but that would be your last 1-byte code point gone (or is there another reason C is not used?) – sanchises 2 days ago
    
You want to get rid of the smiley?? :-P – Luis Mendo 2 days ago

Jelly, 14 bytes

“_|__”ṁ700s70Y

TryItOnline!

How?

“_|__”ṁ700s70Y - Main link: no arguments
“_|__”         - literal ['_','|','_','_']
      ṁ700     - mould like something 700 long
          s70  - split into chunks of length 70
             Y - join with line feeds
share|improve this answer
    
By definition, Jelly cannot be longer than J. – Adám 2 days ago

Javascript REPL, 45 bytes

"_|__".repeat(175).match(/.{70}/g).join("\n")
share|improve this answer
1  
Welcome to PPCG! This should be marked as "JavaScript REPL" or similar, as this doesn't print anything at all outside of an interactive console environment. – Martin Ender 2 days ago
1  
Isn't this 45 bytes? – daHugLenny 2 days ago
    
Thanks! I edited the answer to make it clear – Juan Tonina 2 days ago
    
@daHugLenny you are right, I counted \n as a single byte – Juan Tonina 2 days ago
    
where is the console.log ? – cardeol yesterday

JavaScript (ES6), 48 bytes

f=(n=350)=>n?(n%35?'_':`
_`)+"|_"[n%2]+f(n-1):""

Because recursion.

share|improve this answer

C, 131 115 113 103 97 95 Bytes

i,j;main(){for(;i<10;puts(i++&1?"|__":"|"))for(j=0;j<18-(i&1);printf(&"|___"[j++?0:i&1?1:3]));}

Time to start golfing this...

_|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|
___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|__
_|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|
___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|__
_|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|
___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|__
_|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|
___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|__
_|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|
___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|__
share|improve this answer

Python 2, 46 Bytes

Just using string multiplication to build the string, and slicing to get the right bits :)

k='_|__'*18
print'\n'.join([k[:70],k[2:72]]*5)
share|improve this answer

MATL, 16 bytes

'___|'10:E!70:+)

Try it online!

'___|'   % Push this string
10:E!    % Push [2; 4; 6; ...; 20] (10×1 column vector)
70:      % Push [1, 2, 3, ..., 70] (1×70 row vector)
+        % Add. Gives a 10×70 matrix of all pairwise additions
)        % Index (modular, 1-based) into the string
share|improve this answer
    
Beat you with an entire byte: codegolf.stackexchange.com/a/99073/32352 – sanchises 2 days ago

CJam, 15 bytes

"_|__"175*70/N*

Try it online!

Port of Adnan's 05AB1E answer.

"_|__"             e# Push this string
      175*         e# Repeat 175 times
          70/      e# Split in pieces of size 70
             N*    e# Join by newlines
share|improve this answer

///, 51 bytes

If a trailing newline is allowed:

/e/aaaa//a/_|__//b/eeeea_|//c/__eeeea//d/b
c
/ddddd

Try it online!

share|improve this answer

Haskell, 56 47 bytes

unlines$[1..5]>>take 70.cycle<$>["_|__","___|"]
share|improve this answer

Bash, 44, 41, 40 bytes

printf _\|__%.0s {1..175}|egrep -o .{70}

The printf makes a single line 700 characters long, the egrep matches it 70 characters at a time.

share|improve this answer

Vim, 30 24 keystrokes

18a___|<esc>Y9Pqw2xj$h.<cr>q4@w
share|improve this answer
1  
Nice answer, welcome to the site! Some tips: 1) a takes a count, so you could do 18a___|<esc> instead of making the macro. 2) <cr> in normal mode is equivalent to j0, so you could take one byte off your second macro. – DrMcMoylex yesterday
    
Cool, thanks for the tips! – karpfen yesterday

Retina, 23 21 bytes


175$*
.
_|__
!`.{70}

Try it online

share|improve this answer
    
Use !`.{70} to split the string at the end. – Martin Ender yesterday

Befunge-98, 63 bytes

'_\:3+4%0`!> #0 #\ #|' $ #\_\,1+:7a*%0`!> #0 #, #a_:7aa**\`!#@_

TryItOnline!

share|improve this answer

Python 2, 50 48 bytes

for b in range(10):print('_|__'*175)[b*70:][:70]

2 saved with thanks to @xnor but also thanks to @Shebang for the suggestion :)

share|improve this answer
1  
b*70+70 -> -~b*70 saves a byte :) – Shebang 2 days ago
2  
Or [b*70:][:70]. – xnor 2 days ago
    
Thanks @xnor. Didn't know you could do that. may well go back and trim a couple off some of my other recent answers :) – ElPedro 2 days ago

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.