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

2
\$\begingroup\$

Haskell, 56 47 bytes

unlines$[1..5]>>take 70.cycle<$>["_|__","___|"]
\$\endgroup\$
2
\$\begingroup\$

R, 78 bytes

    strwrap(gsub('(.{70})','\\1 ',paste(rep('___|',175),collapse='')),70)

How?

    x=paste(rep('___|',175),collapse='')   #Creates string on 1 line
    y=gsub('(.{70})','\\1 ',x)             #Adds spaces every 70 characters
    z=strwrap(y,70)                        #Creates a new line every space
    z                                      #Print the finished product
\$\endgroup\$
2
\$\begingroup\$

C, 61 bytes

TCC Version

main(i){for(;i+699;)printf("\n%c"+(--i%70||!i),"___|"[i&3]);}

GCC Version

main(i){for(;i+699;)printf("\n%c"+(i%70||!i),"___|"[--i&3]);}
\$\endgroup\$
1
  • \$\begingroup\$ Welcome to the site! \$\endgroup\$
    – DJMcMayhem
    Commented Nov 11, 2016 at 17:29
2
\$\begingroup\$

Befunge-93, 42 bytes

:4%1g,1+:"F"%!#v_0#@_
_|__~>:+#5,#:4#<1g*`^

Try it online!

\$\endgroup\$
1
  • 1
    \$\begingroup\$ Nice answer. Welcome to the site! \$\endgroup\$
    – DJMcMayhem
    Commented Nov 12, 2016 at 1:43
2
\$\begingroup\$

bash 36 Byte

printf '_|__%.0s' {1..175}|fold -w70

OUtput:

_|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|
___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|__
_|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|
___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|__
_|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|
___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|__
_|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|
___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|__
_|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|
___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|__
\$\endgroup\$
1
  • \$\begingroup\$ You can omit the w in fold -w70 \$\endgroup\$
    – pxeger
    Commented Jan 25, 2021 at 19:27
2
\$\begingroup\$

Retina, 23 21 20 bytes


175$*_

_|_
!`.{70}

Try it online

\$\endgroup\$
2
  • \$\begingroup\$ Use !`.{70} to split the string at the end. \$\endgroup\$ Commented Nov 9, 2016 at 13:59
  • \$\begingroup\$ You can save another byte like this: retina.tryitonline.net/… \$\endgroup\$ Commented Nov 15, 2016 at 21:15
2
\$\begingroup\$

Python 3, 40 bytes

p="_|__"*17
print((p+"_|\n__"+p+"\n")*5)
\$\endgroup\$
2
\$\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\$
2
\$\begingroup\$

Jelly, 13 bytes

70:þ⁵“_|__”ṁY

Try it online!

The dyad given to þ doesn't matter so long as it outputs a scalar, so I chose : solely for aesthetic purposes.

   þ             Take the rangifying outer product
  :              by integer division
70               of 70
    ⁵            and 10,
     “_|__”ṁ     mold "_|__" like it,
            Y    and join on newlines.
\$\endgroup\$
2
\$\begingroup\$

05AB1E, 11 bytes

…_|_ĆƵм×Tä»

Try it online!

         ä   # split...
…            # three char string...
 _|_         # literal...
    Ć        # concatenated with its first character...
       ×     # repeated...
      м      # numeric literal...
     Ƶ       # converted from base 255 to decimal plus 101...
       ×     # times...
         ä   # into...
        T    # 10...
         ä   # equal pieces...
          »  # by newlines
             # implicit output
\$\endgroup\$
1
\$\begingroup\$

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 :)

\$\endgroup\$
3
  • 1
    \$\begingroup\$ b*70+70 -> -~b*70 saves a byte :) \$\endgroup\$
    – Kade
    Commented Nov 8, 2016 at 18:33
  • 2
    \$\begingroup\$ Or [b*70:][:70]. \$\endgroup\$
    – xnor
    Commented Nov 8, 2016 at 18:34
  • \$\begingroup\$ Thanks @xnor. Didn't know you could do that. may well go back and trim a couple off some of my other recent answers :) \$\endgroup\$
    – ElPedro
    Commented Nov 8, 2016 at 18:41
1
\$\begingroup\$

Jolf, 17 bytes

RZc*"_|__"Τ755@FS

Try it here!

Explanation

RZc*"_|__"Τ755@FS
   *"_|__"         repeat this string:
          Τ755      7*5*5 = 175 times
 Zc           @F   chop into groups of 70 (F's charcode)
R               S  join by newlines
\$\endgroup\$
1
\$\begingroup\$

SOML, 16 bytes

_|__”’ø*L{:jjp»»

explanation:

_|__”             push "_|__"
     ’ø           push 18
       *          repeat the "_|__" 18 times
        L{        repeat 10 times:
          :       duplicate the sting
           jj     pop the last 2 letters off
             p    output it
              »»  put the last 2 characters at the start
\$\endgroup\$
1
\$\begingroup\$

GolfSharp, 38 bytes

c(r(175).s(n=>"_|__").j().S(70).j(N));
\$\endgroup\$
2
  • \$\begingroup\$ is it this language? \$\endgroup\$
    – aloisdg
    Commented Oct 25, 2018 at 19:37
  • \$\begingroup\$ @aloisdg it is fellow typo corrector! You warmed my heart \$\endgroup\$ Commented Oct 25, 2018 at 20:18
1
\$\begingroup\$

Pyth, 24 23 22 bytes

VT:*175"_|__"J*70N+70J

OK, I'm still learning. Any hints gratefully received :)

Edit

Saved a byte by moving the assignment of J to first use

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

Racket 159 bytes

(let p((n 2)(x 0)(t 0)(d display))(when(> x 69)(d"\n")(set! x 0))(cond[(> t 699)
(d"\n")][(> n 2)(d"|")(p 0(+ 1 x)(+ 1 t)d)][(d"_")(p(+ 1 n)(+ 1 x)(+ 1 t)d)]))

Ungolfed:

(define (f)
  (let loop ((n 2)   (x 0)   (t 0)  (d display))

    (when (> x 69)  (d "\n")
                    (set! x 0))
    (cond
      [(> t 699)    (d "\n")]

      [(> n 2)      (d "|")
                    (loop    0    (+ 1 x) (+ 1 t) d)]

      [else         (d "_")
                    (loop (+ 1 n) (+ 1 x) (+ 1 t) d)]
      )))

Testing:

(f)

Output:

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

Ruby, 89 80 77 76 72 53 47 42 Bytes

puts (%w[___]*176*?|)[2..-1].scan(/.{70}/)

Demo:

>> puts (%w[___]*176*?|)[2..-1].scan(/.{70}/)
_|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|
___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|__
_|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|
___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|__
_|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|
___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|__
_|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|
___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|__
_|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|
___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|__

Update: I didn’t see there’s already an answer with 30 bytes.

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

PHP, 46 bytes

<?=wordwrap(str_repeat('_|__',175),70,"\n",1);

Output:

C:\PHP>php build-me-a-brick-wall.php
_|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|
___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|__
_|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|
___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|__
_|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|
___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|__
_|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|
___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|__
_|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|
___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|___|__
\$\endgroup\$
8
  • \$\begingroup\$ I think wordwrap()'s 3rd parameter should be "\n" as this currently keeps the string unwrapped in PHP 5.6. \$\endgroup\$
    – manatwork
    Commented Nov 9, 2016 at 14:29
  • \$\begingroup\$ @manatwork In the "test online" link you can check the various versions of PHP, it seems working fine in PHP all versions. \$\endgroup\$
    – Mario
    Commented Nov 9, 2016 at 14:37
  • \$\begingroup\$ Correct, “seems”. But the output is wrapped by the sandbox site, not by PHP. See with “Output: Raw”. \$\endgroup\$
    – manatwork
    Commented Nov 9, 2016 at 14:49
  • \$\begingroup\$ @manatwork I thought the textbox output is acceptable too. I tryed with <?=wordwrap(str_repeat('_|__',175),70,"\n",1); and still no wraps in Raw output while it works fine if you save it in a PHP file and run in a browser. \$\endgroup\$
    – Mario
    Commented Nov 9, 2016 at 14:58
  • \$\begingroup\$ Well, relying on the sandbox sounds similar to what was discussed in When is code that requires a REPL acceptable?. So if you add it to the post title, should be fine. (Honestly, I still not like the idea.) BTW, you can just wrap the line in that place instead of writing \n, to keep the code size at original 45. \$\endgroup\$
    – manatwork
    Commented Nov 9, 2016 at 15:04
1
\$\begingroup\$

Java 8, 128

This code directly calculates each character and has no imports or dependencies.

Golfed:

()->{String s="";for(int x,y=0;y<10;++y){for(x=0;x<70;++x)s+=((y%2<1&(x+3)%4<1)|(y%2>0&(x+1)%4<1))?"|":"_";s+="\n";}return s;}

Ungolfed:

() -> {
  String s = "";
  for (int x, y = 0; y < 10; ++y) {
    for (x = 0; x < 70; ++x)
      s += ((y % 2 < 1 & (x + 3) % 4 < 1) | (y % 2 > 0 & (x + 1) % 4 < 1)) ? "|" : "_";
    s += "\n";
  }
  return s;
}
\$\endgroup\$
1
\$\begingroup\$

Swift 3, 69 bytes

(3...702).map{print($0%4<1 ?"|":"_",terminator:($0-2)%70<1 ?"\n":"")}

Output after compiling and running:

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

Try online here (In this tool it run as script so it will produce a warning due the map result is unused.

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

Clojure, 117 110 bytes

(fn[](println(apply str(map #(str(apply str %)"\n")(partition 70(subs(apply str(repeat 175 "_|__"))0 700))))))

Basically creates a long string of "_|__"s 700 characters long, cuts it every 70 characters, then joins them with newline.

Managed to get rid of the calls to join!

Ungolfed:

(defn build-wall []
  (println
    (apply str
      (map #(str (apply str %) "\n")
        (partition 70
          (subs (apply str
                  (repeat 175 "_|__"))
                0 700))))))
\$\endgroup\$
1
\$\begingroup\$

C#, 106 102 101 118 107 106 100 96 bytes

Thanks shebang for saving 2 bytes and pointing out a mistake, Yodle for saving 6 bytes and Link Ng for saving 4 bytes.

var a="";int i;for(;i++<175;)a+="_|__";for(i=0;i<10;)Console.Write(a.Substring(i++*10,70)+"\n");

You can test it directly on http://csharppad.com/.

\$\endgroup\$
7
  • 1
    \$\begingroup\$ Change the a%2==0 to a%2<1 to save a byte :) \$\endgroup\$
    – Kade
    Commented Nov 8, 2016 at 18:39
  • \$\begingroup\$ Also, you can remove the a++ in the for definition and change a%2 to a++%2! \$\endgroup\$
    – Kade
    Commented Nov 8, 2016 at 18:41
  • \$\begingroup\$ You can save 4 bytes by declaring i outside the loop, incrementing i within the condition i<175, and using i in the second loop instead of a new integer b. \$\endgroup\$
    – Yodle
    Commented Nov 8, 2016 at 19:45
  • \$\begingroup\$ @Yodle I could save 6 bytes by doing so (and not 4), thanks! \$\endgroup\$
    – ave
    Commented Nov 8, 2016 at 19:48
  • \$\begingroup\$ Ahh I guess they have a default value of 0 :P. In VS it won't let you declare local variables without initializing them, so the =0 made it only 4 for me. \$\endgroup\$
    – Yodle
    Commented Nov 8, 2016 at 19:50
1
\$\begingroup\$

Java 8 + Guava, 81 106 bytes

25 bytes for import: com.google.common.base.*;

Lambda that takes no input and returns the required wall.

()->String.join("\n",Splitter.fixedLength(70).split(Strings.repeat("_|__",175)));

Same as many other solutions. Takes a repeating string of "_|__" 175 times, splits it into lengths of 70, then joins them on newline.

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

SAS, 68

option linesize=70;data;length w$700;w=repeat('_|__',174);put w;run;

The 174 is not a typo - in SAS the repeat function rather pedantically returns the original string plus n repeats.

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

Python 3, 43

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

Fixed to be more Trump-like.

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

Kotlin, 99 bytes

fun main(a:Array<String>){"_|__".repeat(999).split(Regex("(?<=\\G.{70})")).take(10).map(::println)}

Regex taken from here. First ever golf, done in 10 minutes, probably improvable..

\$\endgroup\$
4
  • \$\begingroup\$ Welcome to PPCG! Can you remove some of the spaces? Like a:Array<String>? \$\endgroup\$
    – Riker
    Commented Nov 11, 2016 at 17:48
  • \$\begingroup\$ How'd I miss that...thanks. \$\endgroup\$
    – F. George
    Commented Nov 11, 2016 at 17:50
  • \$\begingroup\$ @mEQ5aNLrK3lqs3kfSa5HbvsTWe0nIu What does your name mean? \$\endgroup\$
    – Oliver Ni
    Commented Nov 11, 2016 at 18:04
  • \$\begingroup\$ I use random usernames everywhere, I don't like the possibility of somebody googling my nick and finding out everything about my online life. \$\endgroup\$
    – F. George
    Commented Nov 11, 2016 at 18:07
1
\$\begingroup\$

Lua, 54 bytes

w=("_|__"):rep(17)print((w.."_|\n__"..w.."\n"):rep(5))

No fancy splits for Lua, but it does have an easy repeat.

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

Python 2, 46 bytes

import textwrap as t;print t.fill('_|__'*175)

I was going to do an exec loop similar to @xnor's one alternate solution but he/she got to it before me. I guess I'll just have to let Python do the dirty work for me.

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

R, 62 bytes

Don't have the rep to comment, so posting as an answer: @user3297046's answer can be golfed-down to 62 bytes:

cat(gsub('(.{70})','\\1
',paste(rep('_|__',175),collapse='')))

which results in

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

PHP, 56 bytes

Although I know it can be done smaller using wordwrap or string splits, I prefer more hacky solutions.

for($i=0;$i<700;$i++){echo($i%70?'':'
').'_|___'[$i%4];}
\$\endgroup\$

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.