75
\$\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\$
13
  • 2
    \$\begingroup\$ Related, Related, \$\endgroup\$
    – FlipTack
    Commented Nov 8, 2016 at 18:42
  • 8
    \$\begingroup\$ Also Related. (odd that this should come up today, haha) \$\endgroup\$ Commented Nov 8, 2016 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\$ Commented Nov 10, 2016 at 14:20
  • 2
    \$\begingroup\$ Related! \$\endgroup\$
    – user60199
    Commented Nov 10, 2016 at 17:49
  • 31
    \$\begingroup\$ For bonus points, make Mexico pay for it. \$\endgroup\$ Commented Nov 11, 2016 at 8:26

91 Answers 91

1
\$\begingroup\$

Symbolic Python, 69 bytes

Outputs as a list of lines.

_=-~(_==_)
__=-~_*-~_*_
_=[('_|__'*__)[:-_],('___|'*__)[:-_]]*-~(_*_)

Try it online!

Alternatively, for 16 more bytes, we can print the wall:

_=-~(_==_)
__=-~_*-~_*_
_=(('_|__'*__)[:-_]+"""
"""+('___|'*__)[:-_]+"""
""")*-~(_*_)

Try it online!

\$\endgroup\$
1
\$\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\$
1
\$\begingroup\$

Tcl, 84 78 77 76 bytes

time {append a [expr [incr i]%4-2?"_":"|"];if $i%70<1 {puts $a;unset a}} 700

Try it online!

\$\endgroup\$
2
  • \$\begingroup\$ Interesting trick of append and unset! \$\endgroup\$
    – sergiol
    Commented Nov 30, 2018 at 1:46
  • \$\begingroup\$ @sergiol you sure took your time to reply :P also haven't been using tcl lately. idk if i should start using it again \$\endgroup\$
    – ASCII-only
    Commented Dec 5, 2018 at 11:37
1
\$\begingroup\$

Common Lisp, 70 bytes

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

Try it online!

\$\endgroup\$
1
\$\begingroup\$

C (gcc), 61 58 bytes

-3 bytes thanks to ceilingcat.

f(i){for(i=700;i--;i%70|!i||puts(""))printf(L"__|_"+i%4);}

Try it online!

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

Canvas, 10 bytes

B?³‟‾H×‾7n

Try it here!

Canvas, 10 bytes

αnq[‟5*‾7m

Try it here!

\$\endgroup\$
1
\$\begingroup\$

Vyxal j, 10 bytes

‛_|ǏǏ⁺J*₀/

Try it Online!

How?

‛_|ǏǏ⁺J*₀/
‛_|         # Push string "_|"
   ǏǏ       # Append its first character twice, yielding "_|__"
     ⁺J*    # Repeat it 175 times
        ₀/  # Split into ten equal parts
\$\endgroup\$
0
\$\begingroup\$

Perl, 37 bytes

print$_.$/x!(++$i%35)for('_|',__)x175

Ungolfed:

my $i = 0;
print($_, "\n" x !(++$i % 35)) for ('_|', '__') x 175;
\$\endgroup\$
0
\$\begingroup\$

Lithp, 72 bytes

#::((print (replace (repeat "_|__" 175) (regex "(.{70})" "g") "$1\n"))))

Sample usage:

% wall.lithp
(
    (def x #::((print (replace (repeat "_|__" 175) (regex "(.{70})" "g") "$1\n"))))
    (x)
)

Output:

$ ./run.js wall.lithp
_|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|
___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|__
_|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|
___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|__
_|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|
___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|__
_|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|
___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|__
_|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|
___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|__
\$\endgroup\$
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\$
1
  • \$\begingroup\$ Is it possible to use recursion instead of a for-loop here? That could cut down on some amount of data. \$\endgroup\$ Commented Nov 10, 2016 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\$
1
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
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\$
1
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\$

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\$

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\$
2
  • \$\begingroup\$ would it be shorter to get the ascii value of the new line ? \$\endgroup\$ Commented May 25, 2018 at 9:54
  • \$\begingroup\$ 10 char p is longer than newline. \$\endgroup\$
    – LyricLy
    Commented May 25, 2018 at 10:27
0
\$\begingroup\$

Charcoal, 11 bytes

⪪×¹⁷⁵_|__⁷⁰

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
  • 2
    \$\begingroup\$ It's 8q at the end, not 9q. 9q produces a single underscore on an 11th line. \$\endgroup\$ Commented Nov 13, 2016 at 10:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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