47
\$\begingroup\$

(Inspired by this question)

Objective

Your task is to write a program or function to print an ASCII version of the Stack Overflow logo to STDOUT

 \|/
(-)
(-)
(-)
(-)

Your program should take two inputs, referred to here as H and N. The height of the stack "container" (the parentheses) is determined by H. The number of items in the stack is determined by N. If N>H, the stack will "overflow".

Input/Output

H will determine the height of the containers

For example:

H=1:

( )

H=2:

( )
( )

H=3:

( )
( )
( )

H will always be at least 1

N will determine how many items are in the stack. The following examples are all H = 2:

N=0

( )
( )

N=1

( )
(-)

N=2

(-)
(-)

N=3

 \
(-)
(-)

N=4

 \|
(-)
(-)

N=5

 \|/
(-)
(-)

N=6

 \|/
(-)-
(-)

N=7

 \|/
(-)-
(-)-

N will never be more than 2H+3 (In other words, the stack will never go through the ground).

Rules

  • No Standard Loopholes.
  • Your program must not produce any errors.
  • All test cases must pass.
  • You can input H and N any way you want.
  • I seriously doubt that your language has a built-in for this.
  • Each line may optionally have an extra space at the end. A blank line above a stack where N <= H is optional, as is a trailing newline.
  • This is , so shortest code in bytes wins!

Test Cases

In addition to all of the H=2 test cases from the Input/Output section, all of the following test cases must pass:

H=1, N=1

(-)

H=1, N=5

 \|/
(-)-

H=4, N=7

 \|/
(-)
(-)
(-)
(-)

H=5, N=0

( )
( )
( )
( )
( )

Leaderboards

Here is a Stack Snippet to generate both a regular leaderboard and an overview of winners by language.

To make sure that your answer shows up, please start your answer with a headline, using the following Markdown template:

# Language Name, N bytes

where N is the size of your submission. If you improve your score, you can keep old scores in the headline, by striking them through. For instance:

# Ruby, <s>104</s> <s>101</s> 96 bytes

If there you want to include multiple numbers in your header (e.g. because your score is the sum of two files or you want to list interpreter flag penalties separately), make sure that the actual score is the last number in the header:

# Perl, 43 + 2 (-p flag) = 45 bytes

You can also make the language name a link which will then show up in the leaderboard snippet:

# [><>](http://esolangs.org/wiki/Fish), 121 bytes

var QUESTION_ID=81167,OVERRIDE_USER=41505;function answersUrl(e){return"https://api.stackexchange.com/2.2/questions/"+QUESTION_ID+"/answers?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}function commentUrl(e,s){return"https://api.stackexchange.com/2.2/answers/"+s.join(";")+"/comments?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+COMMENT_FILTER}function getAnswers(){jQuery.ajax({url:answersUrl(answer_page++),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){answers.push.apply(answers,e.items),answers_hash=[],answer_ids=[],e.items.forEach(function(e){e.comments=[];var s=+e.share_link.match(/\d+/);answer_ids.push(s),answers_hash[s]=e}),e.has_more||(more_answers=!1),comment_page=1,getComments()}})}function getComments(){jQuery.ajax({url:commentUrl(comment_page++,answer_ids),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){e.items.forEach(function(e){e.owner.user_id===OVERRIDE_USER&&answers_hash[e.post_id].comments.push(e)}),e.has_more?getComments():more_answers?getAnswers():process()}})}function getAuthorName(e){return e.owner.display_name}function process(){var e=[];answers.forEach(function(s){var r=s.body;s.comments.forEach(function(e){OVERRIDE_REG.test(e.body)&&(r="<h1>"+e.body.replace(OVERRIDE_REG,"")+"</h1>")});var a=r.match(SCORE_REG);a&&e.push({user:getAuthorName(s),size:+a[2],language:a[1],link:s.share_link})}),e.sort(function(e,s){var r=e.size,a=s.size;return r-a});var s={},r=1,a=null,n=1;e.forEach(function(e){e.size!=a&&(n=r),a=e.size,++r;var t=jQuery("#answer-template").html();t=t.replace("{{PLACE}}",n+".").replace("{{NAME}}",e.user).replace("{{LANGUAGE}}",e.language).replace("{{SIZE}}",e.size).replace("{{LINK}}",e.link),t=jQuery(t),jQuery("#answers").append(t);var o=e.language;/<a/.test(o)&&(o=jQuery(o).text()),s[o]=s[o]||{lang:e.language,user:e.user,size:e.size,link:e.link}});var t=[];for(var o in s)s.hasOwnProperty(o)&&t.push(s[o]);t.sort(function(e,s){return e.lang>s.lang?1:e.lang<s.lang?-1:0});for(var c=0;c<t.length;++c){var i=jQuery("#language-template").html(),o=t[c];i=i.replace("{{LANGUAGE}}",o.lang).replace("{{NAME}}",o.user).replace("{{SIZE}}",o.size).replace("{{LINK}}",o.link),i=jQuery(i),jQuery("#languages").append(i)}}var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe",COMMENT_FILTER="!)Q2B_A2kjfAiU78X(md6BoYk",answers=[],answers_hash,answer_ids,answer_page=1,more_answers=!0,comment_page;getAnswers();var SCORE_REG=/<h\d>\s*([^\n,]*[^\s,]),.*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/,OVERRIDE_REG=/^Override\s*header:\s*/i;
body{text-align:left!important}#answer-list,#language-list{padding:10px;width:290px;float:left}table thead{font-weight:700}table td{padding:5px}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b"> <div id="answer-list"> <h2>Leaderboard</h2> <table class="answer-list"> <thead> <tr><td></td><td>Author</td><td>Language</td><td>Size</td></tr></thead> <tbody id="answers"> </tbody> </table> </div><div id="language-list"> <h2>Winners by Language</h2> <table class="language-list"> <thead> <tr><td>Language</td><td>User</td><td>Score</td></tr></thead> <tbody id="languages"> </tbody> </table> </div><table style="display: none"> <tbody id="answer-template"> <tr><td>{{PLACE}}</td><td>{{NAME}}</td><td>{{LANGUAGE}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr></tbody> </table> <table style="display: none"> <tbody id="language-template"> <tr><td>{{LANGUAGE}}</td><td>{{NAME}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr></tbody> </table>

\$\endgroup\$
  • 4
    \$\begingroup\$ May I post a non-competing program that actually overflows the stack instead of printing the logo? \$\endgroup\$ – dorukayhan wants Monica back Jun 4 '16 at 15:14
  • \$\begingroup\$ @dorukayhan If it only overflows when n>h :) \$\endgroup\$ – Daniel M. Jun 4 '16 at 15:20
  • \$\begingroup\$ I mean, may I make a program that crashes from a stack overflow? \$\endgroup\$ – dorukayhan wants Monica back Jun 4 '16 at 15:33
  • \$\begingroup\$ @dorukayhan only if it crashes when there are more items than the stack can hold \$\endgroup\$ – Daniel M. Jun 4 '16 at 15:35

16 Answers 16

14
\$\begingroup\$

Pyth, 43 41 40 bytes

<" \|/"g#0hK-QJEVJs[\(?<N_Kd\-\)*<N-K3\-

Try it online. Test suite.

First pass, quick and dirty. Input to STDIN as N\nH.

Explanation

  1. Save the second input (height) to J (JE), and subtract it from the first input (the number of items). (-QJE)
  2. Save the difference (number of overflowing items) to K. (K-QJE)
  3. Add 1 to the number. (hK-QJE)
  4. Take max(0, previous). This is required as negative numbers would break the next step. (g#0hK-QJE)
  5. Take at most that many letters from the string " \|/" to get the first line and print. (<" \|/"g#0hK-QJE)
  6. Loop N over range(0, J). (VJ) For each N print the concatenation of the following: (s[)
    • "(" (\()
    • " " if there are at least N+1 free spaces in the stack (<N_K), "-" otherwise. (?<N_Kd\-)
    • ")" (\))
    • "-" if there are at least N+4 overflowing pieces in the stack (<N-K3), "" otherwise. (*<N-K3\-)
\$\endgroup\$
13
\$\begingroup\$

JavaScript (ES6), 105 102 bytes

@Edit: Saved 3 bytes thanks to @PatrickRoberts.

f=
(n,h)=>` \\|/`.substr(0,n+1-h)+[...Array(h)].map((_,i)=>`
(${i+n<h?` `:`-`})${i+h+3<n?`-`:``}`).join``
;
<div oninput=o.textContent=f(+n.value,+h.value)>n<input id=n type=number min=0 value=0>h<input id=h type=number min=0 value=0><pre id=o>

\$\endgroup\$
  • \$\begingroup\$ You can replace substring with substr to save 3 bytes, and replace i+n<h?' ':'-' with '- '[i+n<h] to save 2 bytes and replace i+h+3<n?'-':'' with ' -'[i+h+3<n] to save 1 byte. That'll get you under 100 \$\endgroup\$ – Patrick Roberts Jun 3 '16 at 13:27
  • \$\begingroup\$ @PatrickRoberts I couldn't remember whether substr ignored negative subscripts or not, but I can't use your other tips because string subscripts are strings, so booleans aren't good enough. \$\endgroup\$ – Neil Jun 3 '16 at 18:42
  • \$\begingroup\$ crap I forgot about that, good point \$\endgroup\$ – Patrick Roberts Jun 4 '16 at 2:35
  • \$\begingroup\$ Really clever use of tagged template in order to save those two characters! \$\endgroup\$ – Benjamin Gruenbaum Jun 5 '16 at 11:27
  • \$\begingroup\$ @BenjaminGruenbaum what is a "tagged template"? \$\endgroup\$ – Patrick Roberts Jun 6 '16 at 11:52
12
\$\begingroup\$

JavaScript (ES6), 126 122 112 bytes

h=>n=>' \\|/'.substr(0,(o=n-h)+1)+`
( )`[r='repeat'](0>-o?0:-o)+`
(-)-`[r](o=0>o-3?0:o-3)+`
(-)`[r](n<h-o?n:h-o)

Test

f=h=>n=>' \\|/'.substr(0,(o=n-h)+1)+`
( )`[r='repeat'](0>-o?0:-o)+`
(-)-`[r](o=0>o-3?0:o-3)+`
(-)`[r](n<h-o?n:h-o)
document.write(`<pre>${[[2,0],[2,1],[2,2],[2,3],[2,4],[2,5],[2,6],[2,7],[1,1],[1,5],[4,7],[5,0]].map(a=>f(a.shift())(a.shift())).join`

`}</pre>`)

Alternate Test (if your browser does not support ES6)

See the test on Babeljs.io and check "evaluate".

Interesting alternate approach at 136 bytes

h=>n=>' \\|/'.substr(0,(o=n-h)+1)+`
( )${0>-o?0:-o}
(-)-${o=0>o-3?0:o-3}
(-)${n<h-o?n:h-o}`.replace(/(\n.*)(\d+)/g,(_,s,r)=>s.repeat(r))

This moves the repeat amounts into the template string and uses a regexp and replace to inject the repeating groups. Unfortunately the signature for .replace() is just too long.

\$\endgroup\$
  • \$\begingroup\$ I get an error...? \$\endgroup\$ – Addison Crump Jun 3 '16 at 13:46
  • 1
    \$\begingroup\$ @VTCAKAVSMoACE your browser must support ES6 syntax. It works fine for me. Feel free to paste the test into Babel. \$\endgroup\$ – Patrick Roberts Jun 3 '16 at 14:11
  • \$\begingroup\$ @VTCAKAVSMoACE Chrome 52 (in beta as of June 2016) supports all of ES6 and ES7 except tail call optimisation and module loading. \$\endgroup\$ – gcampbell Jun 3 '16 at 18:28
10
\$\begingroup\$

C++14 (lambda function), 196

Saved 1 byte thanks to Quentin.

Saved 2 bytes thanks to Adam Martin.

#include<iostream>
using namespace std;[](int h,int n){auto s=" \\|/( ) (-) (-)-"s;int t=max(min(n-h,3),0);n-=t;cout<<s.substr(0,t+1)+'\n';for(;h;h--)n-=t=n>h?2:h<=n,cout<<s.substr(4+4*t,4)+'\n';}

The function itself takes 157 bytes.

See it in action here.

Ungolfed version:

[](int h, int n) {
    auto s = " \\|/( ) (-) (-)-"s;
    int t = max(min(n - h, 3), 0);
    n -= t;
    cout << s.substr(0, t + 1) + '\n';
    for(; h; h--) {
        if (n > h) t = 2;
        else if (h > n) t = 0;
        else t = 1;
        n -= t;
        cout << s.substr(4 + 4 * t, 4) + '\n';
    }
};
\$\endgroup\$
  • 2
    \$\begingroup\$ I see no point in including includes and using namespace std; in byte count, unless your answer is a complete program (which it isn't). \$\endgroup\$ – Alexander Revo Jun 4 '16 at 21:00
9
\$\begingroup\$

CJam, 57 bytes

Sri:X'(*+X),W%X)X')*+X),X))f+]zN*X5*,X'-*_"\|/"\++ri<S+er

Test it here.

Could definitely use some improvement. The idea is to build a grid where the -\|/- cells are replaced with consecutive integers, e.g.

 345
(2)6
(1)7
(0)8

And then to replace them with the correct characters (potentially spaces) at the end.

\$\endgroup\$
6
\$\begingroup\$

Python 2, 101 100 98 bytes

def f(h,n):
 print" \|/"[:max(0,n-h+1)]
 for i in range(h):print("(-)","( )")[h-i>n]+"-"*(n>i+h+3)
\$\endgroup\$
  • \$\begingroup\$ Spaces after print are unnecessary \$\endgroup\$ – Cyoce Jun 3 '16 at 20:17
  • \$\begingroup\$ @Cyoce Thanks, that saves 2 chars. \$\endgroup\$ – Chuck Morris Jun 3 '16 at 20:43
4
\$\begingroup\$

JavaScript (ES6), 87 80 bytes

F=(h,n)=>h?F(h-1,n-1)+`
(${n>0?'-':' '})${n>2*h+2?'-':''}`:' \\|/'.substr(0,n+1)

Uses recursion to create the output string from the bottom up.

EDIT: Thanks to @Neil for shaving 7 bytes off from 87 bytes

Original

(h,n)=>(E=s=>h--?E(`
(${n>0?'-':' '})${--n>2*h+3?'-':''}`+s):` \\|/`.substr(0,n+1)+s)``

Test snippet:

F=(h,n)=>h?F(h-1,n-1)+`
(${n>0?'-':' '})${n>2*h+2?'-':''}`:' \\|/'.substr(0,n+1)


h.oninput = n.oninput = () => output.innerHTML = F(+h.value, +n.value);
<label>h <input type="number" min="0" value="0" id="h" /></label>
<label>n <input type="number" min="0" value="0" id="n" /></label>
<hr />
<pre id="output"></pre>

\$\endgroup\$
  • \$\begingroup\$ thanks for the nice snippet! Should give an extra point :P \$\endgroup\$ – Kimmax Jun 4 '16 at 23:18
  • 1
    \$\begingroup\$ @Kimmax Thanks mate, no one wants to be messing about with the console \$\endgroup\$ – George Reith Jun 4 '16 at 23:29
  • \$\begingroup\$ At least when I tried, the stack was pretty large, and it would only be 78 bytes with ordinary recursion. \$\endgroup\$ – Neil Jun 6 '16 at 9:45
  • \$\begingroup\$ The snippet console is showing a SyntaxError for me. \$\endgroup\$ – ArtOfCode Jun 6 '16 at 10:25
  • 1
    \$\begingroup\$ @ArtOfCode Need to use an ES6 compliant browser \$\endgroup\$ – George Reith Jun 6 '16 at 10:58
3
\$\begingroup\$

JavaScript (ES6), 149 139 137 bytes

h=>n=>` ${[(g=(j,m=1)=>` -\\|/`[(j<n)*m])(h,2),g(h+1,3),g(h+2,4)].join``}${[...Array(h)].map((_,i)=>`
(${g(h-i-1)})${g(h+i+3)}`).join``}`

I liked @MartinEnder's idea about indexing the -\|/ characters and I wanted to see how it would fare in ES6. Apparently I didn't do so well. Trying to figure out if this could be improved using for...of.

Edits

  • I managed to remove regexp and the call to .replace, moving the indexing directly into g() instead.
  • I accidentally counted f= in the second byte count

Test

f=h=>n=>` ${[(g=(j,m=1)=>` -\\|/`[(j<n)*m])(h,2),g(h+1,3),g(h+2,4)].join``}${[...Array(h)].map((_,i)=>`
(${g(h-i-1)})${g(h+i+3)}`).join``}`
document.write(`<pre>${[[2,0],[2,1],[2,2],[2,3],[2,4],[2,5],[2,6],[2,7],[1,1],[1,5],[4,7],[5,0]].map(a=>f(a.shift())(a.shift())).join`

`}</pre>`)

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

Java, 186 177 bytes

void f(int h,int n){for(int i=0;i<h+1;i++)System.out.print((i>0?"(":" ")+(i>0?n>h-i-2?"-":" ":n>h+0?"\\":" ")+(i>0?")":n>h+1?"|":" ")+(i>0?n>h+2+i?"-":" ":n>h+2?"/":" ")+"\n");}

Ungolfed try online

String f(int h, int n)
{
    String s=" ";
    s+=n>h+0?"\\":" ";
    s+=n>h+1? "|":" ";
    s+=n>h+2? "/":" ";
    s+="\n";

    for(int i=0; i<h; i++)
    {
        s+="(";
        s+=n>h-i-1?"-":" ";
        s+=")";
        s+=n>h+3+i?"-":" ";
        s+="\n";
    }

    return s;
}
\$\endgroup\$
  • \$\begingroup\$ You can save bytes by using a lambda- you can probably even leave out the lambda body \$\endgroup\$ – Daniel M. Jun 3 '16 at 21:48
  • 2
    \$\begingroup\$ Do I need some custom IDE to compile Ungoled Java code? :D \$\endgroup\$ – Kimmax Jun 4 '16 at 23:43
  • \$\begingroup\$ @Kimmax .. D'oh! \$\endgroup\$ – Khaled.K Jun 5 '16 at 7:51
3
\$\begingroup\$

Excel, 131 bytes

Input taken as a tuple, Height H in A1, N in B1. Cell containing formula needs to have Text Wrapping turned on. Suggest using a Mono-spaced font.

=LEFT(" \|/",MAX(0,B1-A1+1))&"
"&REPT("(-)-
",MAX(0,B1-A1-3))&REPT("( )
",MAX(0,A1-B1))&REPT("(-)
",A1-MAX(0,B1-A1-3)-MAX(0,A1-B1))
\$\endgroup\$
  • \$\begingroup\$ Wonderful solution! You should add that this take input as the 2-tuple from A1 and B1 and add the simple note that this does require the calling cell to have the wrap text option to be true. Also maybe that to get the proper alignment it should have a mono-spaced font such as Courier New or Lucidia Console \$\endgroup\$ – Taylor Scott Nov 29 '17 at 20:00
  • 1
    \$\begingroup\$ Thanks @TaylorScott. Updated answer with your suggestions. \$\endgroup\$ – Wernisch Nov 30 '17 at 15:43
2
\$\begingroup\$

C++11, 155 148 145 bytes

void f(int h,int n){cout<<string{" \\|/",max(min(3,n-h),0)+1}<<'\n';for(int i=0;i<h;++i)cout<<(h-i<=n?"(-)":"( )")<<(i<max(n-h-3,0)?"-\n":"\n");}

Ungolfed:

void f(int h,int n)
{
  cout << string{" \\|/", max(min(3, n-h), 0) + 1} << '\n';
  for(int i=0; i<h; ++i)
    cout << (h-i <= n ? "(-)" : "( )") << (i < max(n-h-3,0) ? "-\n" : "\n");
}

Usage:

#include <iostream>
#include <string>
using namespace std;

void f(int h,int n){cout<<string{" \\|/",max(min(3,n-h),0)+1}<<'\n';for(int i=0;i<h;++i)cout<<(h-i<=n?"(-)":"( )")<<(i<max(n-h-3,0)?"-\n":"\n");}

int main()
{
  int h,n;
  cin >> h >> n;
  f(h, n);
}
\$\endgroup\$
1
\$\begingroup\$

Python 3, 134 121 118 111 bytes

def f(h,n):print('\|/'[:max(0,n-h)]+'\n'+'\n'.join('(-)-'if h<n-x-3else('(-)','( )')[x+n<h] for x in range(h)))

Test it here: https://repl.it/CYL1/0

Un-golfed:

def f(h,n):
  top=['\|/'[:max(0,n-h)]]
  stack=['( )'if x+n<h else'(-)'for x in range(h)]
  overflow=top+stack
  v=n-3
  while v>h:
      overflow[h-v]+='-' #add side overflow
      v-=1

  print('\n'.join(overflow))

I'd like to have added the side overflow to the list comprehension, but I couldn't squeeze it in, so I had to go with the while loop. Saved 13 bytes!

\$\endgroup\$
  • \$\begingroup\$ The output is off, you probably need to change the '\|/'[:max(0,n-h)] to be like the Python 2 solution. \$\endgroup\$ – busfault Jun 28 '16 at 19:18
1
\$\begingroup\$

Perl 5, 91 bytes

say((' \|/'=~/./g)[0..-($a=<>)+($b=<>)]);say$b<=$a-$_?'( )':'(-)'.'-'x($b-2>$a+$_)for 1..$a

Try it online!

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

Pip, 50 bytes

Ps.(0Xa."\|/")@<bDC0Fi,aP"()"WV"- "@[b<a-ib<a+4+i]

Try it online!

Ugh, this is too long... don't know how to shorten it any more, though. Cyclical indexing, which is usually helpful, cost extra bytes this time.

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

PowerShell, 109 108 104 bytes

param($n,$h)-join" \|/"[0..(($d=$n-$h),0)[$d-lt0]]
1..$h|%{("( )","(-)")[$h-$_-lt$n]+"-"*($h+$_+2-lt$n)}

Try it online!

Lost a lot on expensive indexing but still decent-ish. I'm not sure my index math is optimal however. Stole some logic from the other answers to save a byte. Also remembered precedence to pop some parens for -4 bytes.

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

05AB1E, 45 bytes

-U…( )¸¹иε²N›ið'-:]RεX4-N@i'-«]" \|/"XdX*>£š»

Can definitely be golfed.. Not too happy about it in its current form tbh.

Try it online or verify all test cases.

Explanation:

-                # Subtract the 2nd (implicit) input `n` from the 1st (implicit) input `h`
                 #  i.e. `h`=3, `n`=8 → 5
 U               # Pop and store it in variable `X`
…( )             # Push string "( )"
    ¸            # Wrap it into a list: ["( )"]
     ¹и          # Repeat it the first input (`h`) amount of times
                 #  i.e. 3 → ["( )","( )","( )"]
ε                # Map each to:
 ²N›i            #  If the second input `n` is larger than the map-index N:
                 #    i.e. `n`=8 >= N=0 → 1 (truthy)
     ð'-:       '#   Replace the space with a "-"
                 #    i.e. "( )" → "(-)"
]                # Close both the if and map
 R               # Reverse the list
ε                # Map each to:
 X4-N@i          #  If `X` minus 4 is larger than or equal to the map-index N:
                 #     i.e. `X`=5 and N=0 → 5-4 >= 0 → 1 (truthy)
                 #     i.e. `X`=5 and N=2 → 5-4 >= 2 → 0 (falsey)
       '-«      '#   Append a "-"
]                # Close both the if and map
 " \|/"          # Push String " \|/"
       Xd        # Check if `X` is 0 or positive (0 if negative, 1 if 0 or positive)
                 #  i.e. `X`=5 → 1 (truthy)
         X*      # Multiply it by `X`
                 #  i.e. 1 * 5 → 5
           >     # Increase it by 1
                 #  i.e. 5 → 6
            £    # Take that many character of the string " \|/"
                 #  i.e. 6 → " \|/"
             š   # Prepend it to the list
                 #  i.e. ["(-)-","(-)-","(-)"] and " \|/" → [" \|/","(-)-","(-)-","(-)"]
              »  # Join the list by newlines (and output implicitly)
                 #  i.e. [" \|/","(-)-","(-)-","(-)"] → " \|/\n(-)-\n(-)-\n(-)"
\$\endgroup\$
  • \$\begingroup\$ If it makes you feel better here's what I had: LR'(ì')«¹x‚3+¬UŸ¦ζJ¹XŸJ¦1úr)˜» and that's only half done. \$\endgroup\$ – Magic Octopus Urn Oct 31 '18 at 15:39

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.