Help Trump build the wall!

69

7

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

J Atkin

Posted 2015-12-23T00:12:17.623

Reputation: 4 846

Answers

9

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.

Magic Octopus Urn

Posted 2015-12-23T00:12:17.623

Reputation: 19 422

29

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=.)

Lynn

Posted 2015-12-23T00:12:17.623

Reputation: 55 648

21What is this I don't even – Conor O'Brien – 2015-12-23T04:03:02.257

4Was this language especially made for this answer? – Erdal G. – 2015-12-23T17:20:25.247

5

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

– Alex A. – 2015-12-23T17:33:03.913

@AlexA. Ok make more sense now. I'm quite new here, thanks! :) – Erdal G. – 2015-12-23T18:07:45.557

@ErdalG. My pleasure. Welcome to the site! – Alex A. – 2015-12-23T18:23:21.420

13

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>

user81655

Posted 2015-12-23T00:12:17.623

Reputation: 10 181

Can you save a byte by using .slice(-15) instead? – Neil – 2015-12-23T14:56:03.010

Fix is easy, just use the right minimum part instead of the left minimum part: __ __ n| |_| | n| |___n - n- n -n— – Neil – 2015-12-23T16:08:58.037

Very clever, nice job! – J Atkin – 2015-12-24T00:00:31.927

@Neil Ah, you're right. Thanks for the tip! – user81655 – 2015-12-24T00:53:56.327

5

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.

Conor O'Brien

Posted 2015-12-23T00:12:17.623

Reputation: 36 228

6@Connor O'Brien so what is the eta looking like on that explanation :D – Rohan Jhunjhunwala – 2016-07-30T20:07:14.757

5

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!

nimi

Posted 2015-12-23T00:12:17.623

Reputation: 34 639

The bottom line should be — (U+2014), not an ASCII dash; I think this means you lose 2 bytes. – Lynn – 2015-12-23T13:56:21.073

@Mauris: you're right. Fixed it. Thanks for finding out. – nimi – 2015-12-23T14:01:53.257

You can actually terminate the periods for lines 1-3 earlier, saving 4+3+3 bytes. (My CJam answer does the same thing.) – Lynn – 2015-12-23T18:07:52.663

@Mauris: ah yes, because the first cycle is cut off after 15 chars. Thanks! – nimi – 2015-12-23T19:09:16.617

4

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ȏǑ
\@\Dk>ĄÚ ܋ɀÜ@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

user2064000

Posted 2015-12-23T00:12:17.623

Reputation: 270

4

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

kuldeep.kamboj

Posted 2015-12-23T00:12:17.623

Reputation: 625

2>

  • 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".
  • < – Blackhole – 2015-12-23T18:42:09.167

    You sir are not portraying the truth. Your code amounts 182 characters, but 212 bytes. – Tschallacka – 2015-12-24T07:26:17.337

    @MichaelDibbets, Sorry confused about bytes vs characters, modified – kuldeep.kamboj – 2015-12-24T07:31:28.713

    1

    use something like https://mothereff.in/byte-counter to count the bytes

    – Tschallacka – 2015-12-24T07:49:59.483

    4

    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
        __   __        __   __        __   __    
       |  |_|  |      |  |_|  |      |  |_|  |   
    ___|       |______|       |______|       |___
    -   -   -   -  -   -   -   -  -   -   -   -  
     - - - - - - -  - - - - - - -  - - - - - - - 
    - - - - - - - -- - - - - - - -- - - - - - - -
    —————————————————————————————————————————————
    

    beatcracker

    Posted 2015-12-23T00:12:17.623

    Reputation: 379

    197 bytes: param($c);' __ __n | |_| |n___| |n- n -n- n—'-split'n'|%{-join($_*15)[0..14]*$c} – mazzy – 2018-06-13T09:05:37.180

    3

    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.

    Level River St

    Posted 2015-12-23T00:12:17.623

    Reputation: 22 049

    Nice but you can save 3 bytes by not using #define q and just hardcoding the values. – Johan du Toit – 2017-05-18T12:43:36.040

    2

    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
    

    dzaima

    Posted 2015-12-23T00:12:17.623

    Reputation: 19 048

    goes back to all ascii-art questions and upvotes dzamia for beating me on literally all of them with SOGL at some point – Magic Octopus Urn – 2018-06-12T18:30:48.860

    2

    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['    __   __    ',
                                        '   |  |_|  |   ',
                                        '___|       |___',
                                        '-   ',
                                        ' -',
                                        '- ',
                                        '—']]
    

    Zenadix

    Posted 2015-12-23T00:12:17.623

    Reputation: 181

    You can remove the spaces to get )for s in[ ... – Cyoce – 2017-03-28T20:02:30.520

    2

    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])."
    ";
    }
    

    Tschallacka

    Posted 2015-12-23T00:12:17.623

    Reputation: 147

    remove the space before the as and remove the brackets -3 Bytes – Jörg Hülsermann – 2017-03-27T14:50:38.050

    $x=$r(' ',3); can be shorten to $x=' '; – Jörg Hülsermann – 2017-03-27T15:01:45.407

    You do not need the brackets for the foreach loop and as$z could write as as$z – Jörg Hülsermann – 2017-03-28T09:44:57.157

    2

    Python 2, (161 characters, 191 bytes)

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

    Cplusplusplus

    Posted 2015-12-23T00:12:17.623

    Reputation: 11

    2

    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!

    Dam Son

    Posted 2015-12-23T00:12:17.623

    Reputation: 21

    1

    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.

    algmyr

    Posted 2015-12-23T00:12:17.623

    Reputation: 858

    0

    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
    

    Kevin Cruijssen

    Posted 2015-12-23T00:12:17.623

    Reputation: 67 575

    0

    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
        __   __        __   __        __   __        __   __        __   __
       |  |_|  |      |  |_|  |      |  |_|  |      |  |_|  |      |  |_|  |
    ___|       |______|       |______|       |______|       |______|       |___
    -   -   -   -  -   -   -   -  -   -   -   -  -   -   -   -  -   -   -   -
     - - - - - - -  - - - - - - -  - - - - - - -  - - - - - - -  - - - - - - -
    - - - - - - - -- - - - - - - -- - - - - - - -- - - - - - - -- - - - - - - -
    ———————————————————————————————————————————————————————————————————————————
    

    mazzy

    Posted 2015-12-23T00:12:17.623

    Reputation: 4 832