73
\$\begingroup\$

Challenge

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!


Winner

The winner goes to Marinus using the APL language, requiring a whole 12 bytes! https://codegolf.stackexchange.com/a/99028/61857


Thank you everyone for participating!

\$\endgroup\$
  • 2
    \$\begingroup\$ Related, Related, \$\endgroup\$ – FlipTack Nov 8 '16 at 18:42
  • 8
    \$\begingroup\$ Also Related. (odd that this should come up today, haha) \$\endgroup\$ – Conor O'Brien Nov 8 '16 at 18:43
  • 1
    \$\begingroup\$ That's OK. I'll let you know when I have a working interpreter. I'm working on it right now, actually :) \$\endgroup\$ – ETHproductions Nov 10 '16 at 14:20
  • 2
    \$\begingroup\$ Related! \$\endgroup\$ – RudolfJelin Nov 10 '16 at 17:49
  • 30
    \$\begingroup\$ For bonus points, make Mexico pay for it. \$\endgroup\$ – Dawood says reinstate Monica Nov 11 '16 at 8:26

86 Answers 86

0
\$\begingroup\$

Batch, 90 bytes

@set s=_________________
@for /l %%i in (1,1,5)do @echo _^|%s:_=___^|%&echo __%s:_=_^|__%

|s cause problems if I want to use them as contents of the variable so it's easiest to stick with them as replace strings.

\$\endgroup\$
0
\$\begingroup\$

Java 7, 136 124 120 115 bytes

String c(){String r,x=r="";int i=999,q=0;for(;i-->0;x+="_|__");for(;i++<10;r+=x.substring(q,q+=70)+"\n");return r;}

Ungolfed & test code:

Try it here.

class M{
  static String c(){
    String r,
           x = r = "";
    int i = 999,
        q = 0;
    for(; i-- > 0; x += "___|");
    for(; i++ < 10; r+= x.substring(q, q+=70) + "\n");
    return r;
  }

  public static void main(String[] a){
    System.out.println(c());
  }
}

Output:

_|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|
___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|__
_|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|
___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|__
_|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|
___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|__
_|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|
___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|__
_|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|
___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|__
\$\endgroup\$
  • \$\begingroup\$ Is it possible to use recursion instead of a for-loop here? That could cut down on some amount of data. \$\endgroup\$ – Clayton Ramsey Nov 10 '16 at 0:55
0
\$\begingroup\$

BASH, 91,34 bytes

printf _\|__%.0s {1..175}|fold -70
\$\endgroup\$
0
\$\begingroup\$

Ruby, 30 bytes

puts ('_|__'*175).scan /.{70}/

Output:

_|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|
___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|__
_|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|
___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|__
_|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|
___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|__
_|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|
___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|__
_|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|
___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|__
\$\endgroup\$
0
\$\begingroup\$

Gema, 45 characters

\A=@subst{<U70>=\$1\\n;@repeat{175;_|__}}@end

Sample run:

bash-4.3$ gema '\A=@subst{<U70>=\$1\\n;@repeat{175;_|__}}@end'
_|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|
___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|__
_|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|
___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|__
_|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|
___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|__
_|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|
___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|__
_|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|
___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|__
\$\endgroup\$
0
\$\begingroup\$

jq, 37 characters

(33 characters code + 4 characters command line options)

range(10)|.*2|("_|__"*70)[.:.+70]
range(10)|("_|__"*70)[.*2:.*2+70]
range(0;20;2)|("_|__"*70)[.:.+70]

Sample run:

bash-4.3$ jq -nr 'range(10)|.*2|("_|__"*70)[.:.+70]'
_|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|
___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|__
_|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|
___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|__
_|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|
___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|__
_|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|
___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|__
_|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|
___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|__

On-line test code 1, code 2 and code 3 (Passing -r through URL is not supported – check Raw Output yourself.)

\$\endgroup\$
0
\$\begingroup\$

Java 8, 101 119 bytes

18 for the import: java.util.stream.*;

Lambda that returns the wall. We generate an infinite Stream of brick pieces ('_|__'), limit it to 175, and collect them into a string. We then use replaceAll to swap in a newline every 70 characters.

()->Stream.generate(()->"_|__").limit(175).collect(Collectors.joining()).replaceAll("(.{70})","$1\n")
\$\endgroup\$
0
\$\begingroup\$

sh (via base64 and pigz) 59 bytes

echo eNqLr4mPpxxzgQjKMRc5mkZdM+oaAG7xGAs=|base64 -D|pigz -d
\$\endgroup\$
0
\$\begingroup\$

Javascript, 232 bytes

brick = ["_","_","_","|"];
brickIndex = 2;
output = "";
for(var y=0;y<10;y++){
    for(var x=0;x<70;x++){
      brickIndex = brickIndex % 4;
      output += brick[brickIndex++];
    }
    output += "\n";
}
console.log(output)
\$\endgroup\$
0
\$\begingroup\$

FurryScript, 71 bytes

A[ <_|> 17 REP +<___|> +BR +<__> 17 REP +<_|__> +BR ]
<<A><A><A><A><A>>

Explanation:

A[ ... ]            {{ Subroutine called A }}
<_|>                {{ Push string "_|" }}
17 REP              {{ Repeat next command 17 times: }}
+<___|>             {{ Concatenate "___|" }}
+BR                 {{ Concatenate newline }}
+<__>               {{ Concatenate "__" }}
17 REP              {{ Repeat next command 17 times: }}
+<_|__>             {{ Concatenate "_|__" }}
+BR                 {{ Concatenate newline }}
<<A><A><A><A><A>>   {{ Template; result of A, 5 times }}
\$\endgroup\$
0
\$\begingroup\$

bash, 35 bytes

printf '\e[8;;70t_|__%.0s' {1..175}

Must be run in graphical terminal as it sets the size of the window.

\$\endgroup\$
0
\$\begingroup\$

Python 3.5.2, 44 bytes

exec("print('_|__'*18);print('___|'*18);"*5)

This is my first attempted golf, so feel free to leave a suggestion!

Try it here

\$\endgroup\$
0
\$\begingroup\$

MySQL, 196 123 118 95 bytes

First wall was backwards, removed procedure.

set @x:=repeat('_|__',99);select left(repeat(concat(left(@x,70),'\n',mid(@x,3,70),'\n'),9),709)
\$\endgroup\$
0
\$\begingroup\$

Python 3 - 41 chars

s="_|__"*17
print((s+"_|\n__"+s+"\n")*5)
\$\endgroup\$
0
\$\begingroup\$

Python 3, 54 bytes

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

I know this is longer than other Python 3 solutions, so I post because it is a different approach.

\$\endgroup\$
0
\$\begingroup\$

Pushy, 21 bytes

`_|__`17:4d;T:vv"^^{{

(non-competing as the language postdates the challenge)

Really wish I could golf it more, will have another go later. It works like so:

`_|__`                  % Push the brick string to the stack
      17:4d;            % Copy 17 times
            T:          % 10 times do:
              vv"^^     %   Print without the last two characters
                   {{   %   Shift the string left twice

Seeing as there's no online interpreter as of yet, here's what it looks like:

$ pushy brickwall.pshy

_|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|
___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|__
_|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|
___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|__
_|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|
___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|__
_|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|
___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|__
_|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|
___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|__
\$\endgroup\$
0
\$\begingroup\$

SOGL V0.12, 10 bytes

Ωo³‘'╥*'4n

Try it Here!

Explanation:

Ωo³‘        push "_|__"
    '╥*     multiply the string 175 times
       '4n  split into lines of length 70
\$\endgroup\$
0
\$\begingroup\$

C (gcc), 61 bytes

f(i){for(i=700;i--;)printf(i%70|!i?"%c":"%c\n","__|_"[i%4]);}

Try it online!

\$\endgroup\$
0
\$\begingroup\$

Japt -R, 15 bytes

AÆ70î"_|__"éX*2

Try it online!

Unpacked & How it works

Ao@70î"_|__"éX*2

Ao@      range(10).map(X=>...)
70î        Repeat the following string to length 70...
"_|__"éX*2   This string rotated X*2 chars to the right.
         `-R` joins the resulting array with newline
         Implicit output
\$\endgroup\$
0
\$\begingroup\$

Brainfuck, 141 bytes

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

Try it online !

My first brainfuck answer !

There is a more aerial and commented version :

+++++[>+++++[>>++++>+++++<<<-]>++>-<<<-]>>>>->  value storage
+++++[                                          doing this ↓ 5 times
  <<.>.>                                        first "_|"
  >++++++++[>++>++<<-]>+>+<                     storing 17 two times
    [<<<<...>.>>>-]                             first 17 "|___" batch
    <<<<<.>>>>>>                                new line
    [<<<<<...>.>>>>-]                           second 17 "|___" batch
  <<<<<..<.>>>-                                 last "__" and new line
]
\$\endgroup\$
0
\$\begingroup\$

Charm, 87 bytes

f := " ___| " 18 repeat
s := substring pstring newline
[ f 2 72 s f 0 70 s ] 5 repeat i

Try it online!

Charm's repeat makes this kind of thing easy, but its syntax prevents very good scores regardless.

Explanation:

f := " ___| " 18 repeat " function to push 18 bricks " pop
s := substring pstring newline " we need to get a substring before printing it with a newline at two different points during the program, so we save bytes defining a function for it " pop
[ f 2 72 s f 0 70 s ] 5 repeat i " now we apply our functions, getting two slightly different substrings of the bricks from the f function and printing them, repeating this 5 times "
\$\endgroup\$
  • \$\begingroup\$ would it be shorter to get the ascii value of the new line ? \$\endgroup\$ – The random guy May 25 '18 at 9:54
  • \$\begingroup\$ 10 char p is longer than newline. \$\endgroup\$ – LyricLy May 25 '18 at 10:27
0
\$\begingroup\$

Charcoal, 11 bytes

⪪×¹⁷⁵_|__⁷⁰

Try it online!

\$\endgroup\$
0
\$\begingroup\$

Prolog (SWI), 83 bytes

?-between(0,699,I),(1 is I mod 4->write("|");write("_")),69 is I mod 70,nl,1=0;1=1.

Try it online!

\$\endgroup\$
0
\$\begingroup\$

Common Lisp, 70 bytes

(dotimes(i 700)(format t"~[|~:;_~]~[
~:;~]"(mod(1- i)4)(mod(1+ i)70)))

Try it online!

\$\endgroup\$
0
\$\begingroup\$

Vim, 26 22 strokes

Assume the q register to be empty (if not type qqq)

175i_|__<esc>0qq70li<enter><esc>q8@q
\$\endgroup\$
  • 1
    \$\begingroup\$ It's 8q at the end, not 9q. 9q produces a single underscore on an 11th line. \$\endgroup\$ – Bart van Nierop Nov 13 '16 at 10:21
0
\$\begingroup\$

JavaScript (Node.js), 45 bytes

_=>`_|__`.repeat(175).match(/.{70}/g).join`
`

Try it online!

Explanation :

_ =>                    // lambda function (argument passed to save a byte)
    `_|__`              // simple enough
    .repeat(175)        // repeat the above mentioned shape 175 times
    .match(/.{70}/g)    // simple regexp to match a shape 70 (something :) ) long 
    .join`\n`           // and join them on a new line

Simple enough.

Alternate version :

JavaScript (Node.js), 714 bytes

_=>`_|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|
___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|__
_|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|
___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|__
_|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|
___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|__
_|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|
___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|__
_|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|
___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|__`

Try it online!

No explanation required. Simple hard coded.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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