67
\$\begingroup\$

Trump needs the wall constructed and you are going to do it! To most efficiently build his wall I have created a simple, repeatable pattern for you to use:

    __   __    
   |  |_|  |   
___|       |___
-   -   -   -  
 - - - - - - - 
- - - - - - - -
———————————————

Trump will tell you how many wall segments he needs and you will build them to look just like this.

Here is the pattern:

    __   __     <-- 4-2-3-2-4          ' _ _ '
   |  |_|  |    <-- 3-1-2-1-1-1-2-1-3  ' | |_| | '
___|       |___ <-- 3-1-7-1-3          '_| |_'
-   -   -   -   <-- 1-3-1-3-1-3-1-1    '- - - - '
 - - - - - - -  <-- 1-1-...-1-1        ' - -...- - '
- - - - - - - - <-- 1-1-...-1-1        '- - ... - -'
——————————————— <-- 15                 Unicode U+2014

Input will always be an integer >0.

Test cases:

1
    __   __    
   |  |_|  |   
___|       |___
-   -   -   -  
 - - - - - - - 
- - - - - - - -
———————————————

2
    __   __        __   __    
   |  |_|  |      |  |_|  |   
___|       |______|       |___
-   -   -   -  -   -   -   -  
 - - - - - - -  - - - - - - - 
- - - - - - - -- - - - - - - -
——————————————————————————————

5
    __   __        __   __        __   __        __   __        __   __
   |  |_|  |      |  |_|  |      |  |_|  |      |  |_|  |      |  |_|  |
___|       |______|       |______|       |______|       |______|       |___
-   -   -   -  -   -   -   -  -   -   -   -  -   -   -   -  -   -   -   -
 - - - - - - -  - - - - - - -  - - - - - - -  - - - - - - -  - - - - - - - 
- - - - - - - -- - - - - - - -- - - - - - - -- - - - - - - -- - - - - - - -
———————————————————————————————————————————————————————————————————————————

Since you need to do this fast, write the shortest program possible!

If it helps, I wrote the challenge first, title last ;)

\$\endgroup\$

17 Answers 17

8
\$\begingroup\$

05AB1E, 38 bytes

•4H’*»È%f·ù„áÅ'4•4B3ÝJ"_ -|"‡8ô€ûvy¹×»

Try it online!

•4H’*»È%f·ù„áÅ'4•     # Push '1724427993555739020619095486300160'
4B                    # Convert to base 4 (turns it into an 8x8 bitmap).
  3ÝJ"_ -|"‡          # Replace digits 0-3 with _, , -, or |.
            8ô        # Split into pieces of 8.
              €û      # Palindromize each piece.
                vy¹×» # For each row, dupe it n times (hori) and print it.

1724427993555739020619095486300160 converted to base-4:

11110011111311300003111121112111121212122121212100000000

11110011111311300003111121112111121212122121212100000000 with characters replaced:

__ | |____| - - - - - -- - - - ________

Previous pattern split into 8 pieces:

    __  
   |  |_
___|    
-   -   
 - - - -
- - - - 
________

Then you palindromize, and make it as long as needed through repetition.

\$\endgroup\$
29
\$\begingroup\$

CJam, 52 bytes

F,ri*"s@;b6(MBZF,fu"128b6b"_ 
|-—"f=N/ff=zN*

Includes a bunch of unprintable ASCII characters. The hexdump of the first string literal pushed is:

01 73 06 40 3B 62 36 28 1E 4D 07 42 5A 14 1B 46 2C 66 75

Try it here!

Explanation

The above hexdump is interpreted as a base-128 number, then converted to base 6, to get this list:

[1 1 1 1 0 0 1 1 1 0 0 2
 1 1 1 3 1 1 3 0 3 1 1 3 2
 0 0 0 3 1 1 1 1 1 1 1 3 2
 4 1 1 1 2
 1 4 2
 4 1 2
 5]

To this, we apply the mapping 0 → _, 1 → space, 2 → \n, 3 → |, 4 → -, 5 → —. This gets us the string:

    __   __
   |  |_|  |
___|       |
-   
 -
- 
—

It consists of the "period" of each line; i.e. we can cycle the fifth line " -" to get " - - - - - - - ".

Then, we execute this subprogram:

N/               Split into lines.
  Ff*            Repeat each line 15 times (to cycle it).
     Ff<         Take the first 15 chars of each line.
        rif*     Repeat these chars input() times.
            N*   Join lines.

(The new version does this in a slightly different way that I actually can't wrap my head around myself very well, because it uses ff=.)

\$\endgroup\$
  • 21
    \$\begingroup\$ What is this I don't even \$\endgroup\$ – Conor O'Brien Dec 23 '15 at 4:03
  • 4
    \$\begingroup\$ Was this language especially made for this answer? \$\endgroup\$ – Erdal G. Dec 23 '15 at 17:20
  • 5
    \$\begingroup\$ @ErdalG. No. Though CJam was indeed made by a PPCG regular (aditsu), it's been around for quite some time. You'll find it all over the site. :) \$\endgroup\$ – Alex A. Dec 23 '15 at 17:33
  • \$\begingroup\$ @AlexA. Ok make more sense now. I'm quite new here, thanks! :) \$\endgroup\$ – Erdal G. Dec 23 '15 at 18:07
  • \$\begingroup\$ @ErdalG. My pleasure. Welcome to the site! \$\endgroup\$ – Alex A. Dec 23 '15 at 18:23
13
\$\begingroup\$

JavaScript (ES6), 116 115 bytes

n=>"__   __    n|  |_|  |   n|       |___n -  n- n -n—".split`n`.map(l=>l.repeat(15).slice(-15).repeat(n)).join`
`

Saved a byte thanks to @Neil!

Explanation

Pretty much the same as @Mauris' CJam method, but without the character mapping.

The wall parts are in the format:

__   __    
|  |_|  |   
|       |___
 -  
- 
 -
—

because if you repeat each line 15 times you get:

...    __   __    __   __    __   __    
... |  |_|  |   |  |_|  |   |  |_|  |   
... |       |___|       |___|       |___
 -   -   -   -   -   -   -   -   -   -  
          - - - - - - - - - - - - - - - 
           - - - - - - - - - - - - - - -
                         ———————————————

and after slicing to just the last 15 characters you get:

    __   __    
   |  |_|  |   
___|       |___
-   -   -   -  
 - - - - - - - 
- - - - - - - -
———————————————

Ungolfed

n=>

  // array of wall line parts
  "__   __    n|  |_|  |   n|       |___n -  n- n -n—".split`n`

  .map(l=>       // for each wall line
    l.repeat(15) // repeat the line 15 times to create a complete wall line
    .slice(-15)  // each wall piece is only 15 characters long
    .repeat(n)   // repeat the wall n times
  )
  .join`
`                // output the resulting wall

Test

var solution = n=>"__   __    n|  |_|  |   n|       |___n -  n- n -n—".split`n`.map(l=>l.repeat(15).slice(-15).repeat(n)).join`
`
<input type="number" oninput="result.textContent=solution(+this.value)" />
<pre id="result"></pre>

\$\endgroup\$
  • \$\begingroup\$ Can you save a byte by using .slice(-15) instead? \$\endgroup\$ – Neil Dec 23 '15 at 14:56
  • \$\begingroup\$ Fix is easy, just use the right minimum part instead of the left minimum part: __ __ n| |_| | n| |___n - n- n -n— \$\endgroup\$ – Neil Dec 23 '15 at 16:08
  • \$\begingroup\$ Very clever, nice job! \$\endgroup\$ – J Atkin Dec 24 '15 at 0:00
  • \$\begingroup\$ @Neil Ah, you're right. Thanks for the tip! \$\endgroup\$ – user81655 Dec 24 '15 at 0:53
5
\$\begingroup\$

Jolf, 135 bytes

Considerable golfing can be done. Turn off pretty print and clear the output for a better result. Try it here!. Also, use this to test an arbitrary number with more ease.

oHpAt++++++++++++*"    __   __    "jH*"   |  |_|  |   "jH*"___|       |___"jH*j"-   -   -   -  "H*+*" -"7' jH*"- - - - - - - -"jH*M35j'—

I will add an explanation later.

\$\endgroup\$
  • 5
    \$\begingroup\$ @Connor O'Brien so what is the eta looking like on that explanation :D \$\endgroup\$ – Rohan Jhunjhunwala Jul 30 '16 at 20:07
5
\$\begingroup\$

Haskell, 116 118 108 bytes

h n=take(n*15).cycle
f n=unlines$h n.h 1<$>lines"    __   __\n   |  |_|  |\n___|       |\n-   \n -\n- \n—"

Usage example:

*Main> putStr $ f 3
    __   __        __   __        __   __    
   |  |_|  |      |  |_|  |      |  |_|  |   
___|       |______|       |______|       |___
-   -   -   -  -   -   -   -  -   -   -   -  
 - - - - - - -  - - - - - - -  - - - - - - - 
- - - - - - - -- - - - - - - -- - - - - - - -
—————————————————————————————————————————————

This uses the same strategy as other answers here: each line of the wall is one cycle of the pattern, e.g. "- " (dash + space) for the second last line. Repeat each pattern, take 15 chars to get one wall segment, repeat again and take 15*n chars for n segments.

Edit: @Mauris found 10 bytes. Thanks!

\$\endgroup\$
  • \$\begingroup\$ The bottom line should be — (U+2014), not an ASCII dash; I think this means you lose 2 bytes. \$\endgroup\$ – Lynn Dec 23 '15 at 13:56
  • \$\begingroup\$ @Mauris: you're right. Fixed it. Thanks for finding out. \$\endgroup\$ – nimi Dec 23 '15 at 14:01
  • \$\begingroup\$ You can actually terminate the periods for lines 1-3 earlier, saving 4+3+3 bytes. (My CJam answer does the same thing.) \$\endgroup\$ – Lynn Dec 23 '15 at 18:07
  • \$\begingroup\$ @Mauris: ah yes, because the first cycle is cut off after 15 chars. Thanks! \$\endgroup\$ – nimi Dec 23 '15 at 19:09
4
\$\begingroup\$

Bash + Linux utilities (247 186 180 bytes)

read x
for i in {1..7}
do
tail -n +7 $0|gzip -dc|sed -nr "$i s/(.*)/$(printf '\\1%.0s' $(seq 1 $x))/p"
done
exit
ˈ ELzVSPPPȏǑ
\@\D񵠚k>ĄÚ ܋ɀÜ@r²uٞ5L! 󰰹͠  

Since unprintable characters have been generously used in the construction of the above script, here's a hexdump:

00000000  72 65 61 64 20 78 0a 66  6f 72 20 69 20 69 6e 20  |read x.for i in |
00000010  7b 31 2e 2e 37 7d 0a 64  6f 0a 74 61 69 6c 20 2d  |{1..7}.do.tail -|
00000020  6e 20 2b 37 20 24 30 7c  67 7a 69 70 20 2d 64 63  |n +7 $0|gzip -dc|
00000030  7c 73 65 64 20 2d 6e 72  20 22 24 69 20 73 2f 28  ||sed -nr "$i s/(|
00000040  2e 2a 29 2f 24 28 70 72  69 6e 74 66 20 27 5c 5c  |.*)/$(printf '\\|
00000050  31 25 2e 30 73 27 20 24  28 73 65 71 20 31 20 24  |1%.0s' $(seq 1 $|
00000060  78 29 29 2f 70 22 0a 64  6f 6e 65 0a 65 78 69 74  |x))/p".done.exit|
00000070  0a 1f 8b 08 00 45 4c 7a  56 02 03 53 50 50 50 88  |.....ELzV..SPPP.|
00000080  8f 87 11 0a 5c 40 5c 03  44 f1 35 60 5a 81 2b 3e  |....\@\.D.5`Z.+>|
00000090  1e c4 04 83 1a 20 9b 4b  17 c8 40 c2 5c 40 02 19  |..... .K..@.\@..|
000000a0  72 a1 72 75 b9 1e 35 4c  21 1e 01 00 f3 30 f0 f9  |r.ru..5L!....0..|
000000b0  8d 00 00 00                                       |....|
000000b4
\$\endgroup\$
4
\$\begingroup\$

PowerShell, 103 100 characters (105 bytes on disk, 102 w/o BOM)

Pretty much the same as @user81655 method.

Param($c)'    __   __n   |  |_|  |n___|       |n-   n -n- n—'-split'n'|%{($_*15).Substring(0,15)*$c}

Ungolfed version

# Assign input to variable,
Param($c)

# Split array of wall parts and send them down the pipeline
'    __   __n   |  |_|  |n___|       |n-   n -n- n—' -split 'n' |
    ForEach-Object { # For each piece of wall
        ($_*15) # Repeat the line 15 times to create a complete wall line
        .Substring(0,15) # Each wall piece is only 15 characters long
        *$c # Repeat the wall n times
    }

Usage example

PS> .\TrumpWall.ps1 3
    __   __        __   __        __   __    
   |  |_|  |      |  |_|  |      |  |_|  |   
___|       |______|       |______|       |___
-   -   -   -  -   -   -   -  -   -   -   -  
 - - - - - - -  - - - - - - -  - - - - - - - 
- - - - - - - -- - - - - - - -- - - - - - - -
—————————————————————————————————————————————
\$\endgroup\$
  • 1
    \$\begingroup\$ 97 bytes: param($c);' __ __n | |_| |n___| |n- n -n- n—'-split'n'|%{-join($_*15)[0..14]*$c} \$\endgroup\$ – mazzy Jun 13 '18 at 9:05
4
\$\begingroup\$

PHP 5.4, ( 182 175 characters )

foreach(['    __   __    ','   |  |_|  |   ','___|       |___','-   -   -   -  ', ' - - - - - - - ','- - - - - - - -','———————————————'] as$d)echo str_repeat($d,$argv[1])."\n";

Ungolfed Version

$s=['    __   __    ',
    '   |  |_|  |   ',
    '___|       |___',
    '-   -   -   -  ',
    ' - - - - - - - ',
    '- - - - - - - -',
    '———————————————'
];
foreach($s as $d) {
    echo str_repeat($d,$argv[1])."\n";
}

[ 7 characters saved by follow Blackhole suggestion. ]

Another version with less bytes but more characters

PHP 5.4, ( 176 characters, 178 bytes )

foreach(['    __   __    ','   |  |_|  |   ','___|       |___','-   -   -   -  ',' - - - - - - - ','- - - - - - - -',str_repeat('—',15)] as$d)echo str_repeat($d,$argv[1])."\n";

Just replace 15 instances of m-dash with one dash with str_repeat function

\$\endgroup\$
  • 2
    \$\begingroup\$ 1) Don't define a variable for $s, use it directly in your loop: foreach([…,…] as $d) 2) Remove the unless space before $d: foreach(… as$d) 3) Use a newline instead of "\n". \$\endgroup\$ – Blackhole Dec 23 '15 at 18:42
  • \$\begingroup\$ You sir are not portraying the truth. Your code amounts 182 characters, but 212 bytes. \$\endgroup\$ – Tschallacka Dec 24 '15 at 7:26
  • \$\begingroup\$ @MichaelDibbets, Sorry confused about bytes vs characters, modified \$\endgroup\$ – kuldeep.kamboj Dec 24 '15 at 7:31
  • 1
    \$\begingroup\$ use something like mothereff.in/byte-counter to count the bytes \$\endgroup\$ – Tschallacka Dec 24 '15 at 7:49
3
\$\begingroup\$

C, 148 bytes

#define q 16843009
i;p[]={-1,q*17,q*68,q*16,-8388417,8577152,3936000};
f(n){for(i=n*105;i--;i%(15*n)||puts(""))putchar(" -|_"[p[i/15/n]>>i%15*2&3]);}

Score excludes the unnecessary newline before f(n) which is included for clarity.

the magic numbers in p encode the characters for the wall in base 4, which are reconstructed from the string " -|_" 0,1,2,3 respectively

16843009 in hex is 0x1010101. this is used for the lines with - in them.

Because _ is encoded by 3, the bottom line can be encoded simply as -1, which is the number with all the bits set to 1.

\$\endgroup\$
  • \$\begingroup\$ Nice but you can save 3 bytes by not using #define q and just hardcoding the values. \$\endgroup\$ – Johan du Toit May 18 '17 at 12:43
2
\$\begingroup\$

Vitsy, 121 bytes

How I do this is by accessing each line one at a time input times, giving me stacks with the contents of each line. Then, I output a line at a time. If anyone wants me to give a more in-depth explanation, just ask (I'm currently opening presents, so...).

V0v7\[v1+v&V\[vDvm]a]y\[?Z]
"    __   __    "
"   |  |_|  |   "
"___|       |___"
4\["-   "]Xr
6mXr" "
8\["- "]X
"—"e\D

Try it online!

\$\endgroup\$
2
\$\begingroup\$

PHP5.5, 182 172 bytes 168 bytes

based on @kuldeep.kamboj's answer, which is actually 212 bytes the moment I write this but 182 characters. I wish the wall was a bit higher, then I could do some more optimisation ;-)

this one is 168 bytes, thanks to @JörgHülsermann

$r='str_repeat';$d=$r(' -',7);$x='   ';foreach(["$x __   __ $x","$x|  |_|  |$x","___|$x$x |___","-$x-$x-$x-  ","$d ","-$d",$r('—',15)] as$z){echo$r($z,$argv[1])."
";}

This one is 172 bytes

$r='str_repeat';$d=$r(' -',7);$x=$r(' ',3);foreach(["$x __   __ $x","$x|  |_|  |$x","___|$x$x |___","-$x-$x-$x-  ","$d ","-$d",$r('—',15)] as$z){echo$r($z,$argv[1])."
";}

This one is 182 bytes :-)

$r='str_repeat';$d=$r(' -',7);$x=$r(' ',4);foreach([$x.'__   __'.$x,'   |  |_|  |   ','___|       |___','-   -   -   -  ',$d.' ','-'.$d,$r('—',15)] as$z){echo $r($z,$argv[1]).'
';}

ungolfed version

$r='str_repeat';
$d=$r(' -',7);
$x=$r(' ',3);
$s=["$x __   __ $x",
    "$x|  |_|  |$x",
    "___|$x$x |___",
    "-$x-$x-$x-  ",
    "$d ",
    "-$d",
    $r('—',15)
];
foreach($s as $z) {
  echo$r($z,$argv[1])."
";
}
\$\endgroup\$
  • \$\begingroup\$ remove the space before the as and remove the brackets -3 Bytes \$\endgroup\$ – Jörg Hülsermann Mar 27 '17 at 14:50
  • \$\begingroup\$ $x=$r(' ',3); can be shorten to $x=' '; \$\endgroup\$ – Jörg Hülsermann Mar 27 '17 at 15:01
  • \$\begingroup\$ You do not need the brackets for the foreach loop and ` as$z` could write as as$z \$\endgroup\$ – Jörg Hülsermann Mar 28 '17 at 9:44
2
\$\begingroup\$

Python 3, 132 122 120 bytes

def f(n):[print((s*15*n)[:15*n])for s in['    __   __    ','   |  |_|  |   ','___|       |___','-   ', ' -', '- ', '—']]

Ungolfed:

def f(n):
    [print((s*15*n)[:15*n])for s in['    __   __    ',
                                    '   |  |_|  |   ',
                                    '___|       |___',
                                    '-   ',
                                    ' -',
                                    '- ',
                                    '—']]
\$\endgroup\$
  • \$\begingroup\$ You can remove the spaces to get )for s in[ ... \$\endgroup\$ – Cyoce Mar 28 '17 at 20:02
2
\$\begingroup\$

Python 2, (161 characters, 191 bytes)

x=input();a=['    __   __    ','   |  |_|  |   ','___|       |___','-   -   -   -  ',' - - - - - - - ','- - - - - - - -','———————————————']
for i in a:print i*x
\$\endgroup\$
2
\$\begingroup\$

SOGL V0.12, 32 bytes

→↔\ιδ»►℮⁰}▒║ΙOģΠp~⁵‘ ¾“ζ'¹*+'¹n*

Try it Here!

Explanation:

...‘ ¾“ζ'¹*+'¹n*
...‘              push a string of the top 6 lines of 1 wall piece (no newlines)
     ¾“           push 8212
       ζ          convert to char from unicode codepoint
        '¹*       repeat 15 times
           +      add that to the previous compressed string
            '¹n   split into lines with length 15
               *  repeat horizontally input times
\$\endgroup\$
  • \$\begingroup\$ goes back to all ascii-art questions and upvotes dzamia for beating me on literally all of them with SOGL at some point \$\endgroup\$ – Magic Octopus Urn Jun 12 '18 at 18:30
1
\$\begingroup\$

Vim, 90 keys

Assuming the input is in a buffer by itself the following will do the job (newline only for readability)

"aDi    __   __    ^M   |  |_|  |   ^M___|       |___^M^[
4i-   ^[xo-^[Y7P8JY2PxA ^[GVr^K-M^Vgg$d@aP

where ^M is a return, ^[ is escape, ^K is ctrl+k and ^V is ctrl+v.

This can very likely be golfed down quite a bit, as there might be much better ways of generating the pattern.

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

Java 11, 236 235 231 229 bytes

n->{String w[]={"","","","","","",""},t="- ".repeat(7);for(;n-->0;w[0]+="x __x__x ",w[1]+="x|  |_|  |x",w[2]+="___|xx |___",w[3]+="-x-x-x-  ",w[4]+=" "+t,w[5]+=t+"-")w[6]+="_".repeat(15);return"".join("\n",w).replace("x","   ");}

Try it online.
NOTE: Java 11 isn't on TIO yet, so String.repeat(int) has been emulated with repeat(String,int) (for the same byte-count).

Explanation:

n->{                                // Method with integer parameter and String return-type
  String w[]={"","","","","","",""},//  Start with seven empty rows
         t="- ".repeat(7);          //  Temp String to reduce bytes
  for(;n-->0;                       //  Loop `n` amount of times:
    w[0]+="x __x__x ",              //   Append to the first row
    w[1]+="x|  |_|  |x",            //   Append to the second row
    w[2]+="___|xx |___",            //   Append to the third row
    w[3]+="-x-x-x-  ",              //   Append to the fourth row
    w[4]+=" "+t,                    //   Append to the fifth row
    w[5]+=t+"-")                    //   Append to the sixth row
    w[6]+="_".repeat(15);           //   Append to the seventh row
  return"".join("\n",w)             //  Join all rows by new-lines
          .replace("x","   ");}     //  Then replace all "x" with three spaces,
                                    //  and return the result
\$\endgroup\$
0
\$\begingroup\$

Powershell + file, 92 bytes

save powershell to get-trumpwall.ps1 (40 bytes)

param($c);gc f|%{-join($_*15)[0..14]*$c}

save data file with name f and data contains Unicode symbol and Linux LF only (52 bytes):

    __   __
   |  |_|  |
___|       |
-   
 -
- 
—

hex dump:

0000000000: 20 20 20 20 5F 5F 20 20 │ 20 5F 5F 0A 20 20 20 7C      __   __◙   |
0000000010: 20 20 7C 5F 7C 20 20 7C │ 0A 5F 5F 5F 7C 20 20 20    |_|  |◙___|
0000000020: 20 20 20 20 7C 0A 2D 20 │ 20 20 0A 20 2D 0A 2D 20      |◙-   ◙ -◙-
0000000030: 0A E2 80 94             │                          ◙—››

Usage example

PS> .\get-trumpwall.ps1 5
    __   __        __   __        __   __        __   __        __   __
   |  |_|  |      |  |_|  |      |  |_|  |      |  |_|  |      |  |_|  |
___|       |______|       |______|       |______|       |______|       |___
-   -   -   -  -   -   -   -  -   -   -   -  -   -   -   -  -   -   -   -
 - - - - - - -  - - - - - - -  - - - - - - -  - - - - - - -  - - - - - - -
- - - - - - - -- - - - - - - -- - - - - - - -- - - - - - - -- - - - - - - -
———————————————————————————————————————————————————————————————————————————
\$\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.