The Staircase Challenge

20

4

Your work is to recreate this piece of art:

                        _____
                       |
                       |
                       |
                       |
                  _____| 
                 |
                 |
                 |
                 |
            _____|
           |
           |
           |
           |
      _____|
     |
     |
     |
     |
_____|

The answer must recreate this and print this as a result. All languages allowed, no direct printing of art, ofc, some level of manipulation is required. The answer with the least bytes wins.

Closes on Thursday 6:30 AM UTC or so.

The original thing was shown to me by my friend who did this with Java, he refused to show me the source code and now I'll dazzle him with the brilliance of other languages possibly. :D

You cannot use any alternative character (makes it easier?).


Current leader board

  1. Pyth - 28 bytes - isaacg
  2. CJam - 30 bytes - Runer112
  3. CJam - 32 bytes - Martin Büttner

Highest votes: C - 73 bytes - Paul R


isaacg takes the crown for passing the Staircase Challenge with Pyth. Watch out for more challenges like these on PPCG!

therewillbecoffee

Posted 2015-03-02T15:06:00.153

Reputation: 307

1Welcome to Programming Puzzles & Code Golf Stack Exchange! All challenges here require an objective winning criterion, to indisputably decide which solution should win. This looks like a [tag:code-golf] question, i.e. shortest code wins, but I'll let you edit it in yourself in case you want to make it something different. Thanks! – Doorknob – 2015-03-02T15:08:27.600

I did mention that the one with the least bytes wins. – therewillbecoffee – 2015-03-02T15:10:23.277

1Ah, sorry, I missed that. I've edited the proper tag into your question, then. – Doorknob – 2015-03-02T15:11:08.887

@Doorknob This is interesting. We ec-ed twice apparently, explains the loss the information which I had to readd. – therewillbecoffee – 2015-03-02T15:15:43.153

13Do we have to print that 1 weird trailing space on the 6th line ? – Optimizer – 2015-03-02T15:45:09.640

4More generally, is trailing space allowed? Can I pad this to a rectangle of the width of the first line? – Martin Ender – 2015-03-02T15:56:39.260

8Can we have a trailing newline? – TheNumberOne – 2015-03-02T16:26:46.710

1@Optimizer Nope, not necessary. Anything that looks necessarily similar is permitted in accordance to what I stated above. – therewillbecoffee – 2015-03-02T16:53:36.520

1@MartinBüttner Well, since a trailing newline would reduce the bytes, everyone can do it. No probs. I'm looking for the most optimized code. – therewillbecoffee – 2015-03-02T16:54:37.160

Answers

4

Pyth, 29 28

V21++**6/-20N5d*5?d%N5\_<\|N

Try it here.

A pretty straightforward solution, with the "append five spaces or five underscores" trick from @xnor's solution, but with the loop from 0 to 20, not 20 to 0.

isaacg

Posted 2015-03-02T15:06:00.153

Reputation: 39 268

1I dub you thee, Sir isaacg for passing the Staircase Challenge. – therewillbecoffee – 2015-03-06T11:24:16.070

...and now you can enter the staircase – Anthony Pham – 2015-08-18T20:42:44.070

22

C, 86 80 76 75 73 bytes

c;main(i){for(i=21;i--;c='|')printf("%*s%c\n",i/5*6+5,i%5?"":"_____",c);}

Paul R

Posted 2015-03-02T15:06:00.153

Reputation: 2 893

5There always has to be that guy who will post a C solution. Upvote for you. – therewillbecoffee – 2015-03-02T17:56:47.850

1You could get it even shorter by changing the loop to for(i=25;i--;) – Felix Bytow – 2015-03-02T18:02:01.350

1@FelixBytow It should be i=26. Besides this, the ' ' could be changed to 32 for an extra character. My solution is 2 characters longer after these optimizations :( – Allbeert – 2015-03-02T18:37:29.250

2You seem to have an extra step. there are 21 rows in the required output, not 26. Some more optimizations: main(i){for(i=21;i--;)printf("%*s%c\n",i/5*6+5,i%5?"":"_____",i<20?'|':0);} 1. Simplify the formula for length 2. As @Allbeert says, you can use the ascii code for ' ' but why stop at ASCII 32 when ASCII 0 will do. Also it runs fine for me with "" instead of " " – Level River St – 2015-03-02T18:54:36.103

Thanks for all the suggestions guys, and for noticing that I had one stair too many! – Paul R – 2015-03-02T19:20:43.093

For i<20?'|':0 substitute i<20||'|' for one character. – FUZxxl – 2015-03-03T00:06:02.120

@FUZxxl: nice idea but it doesn't seem to work - I haven't quite worked out whether it's a problem with operator precedence or something else. – Paul R – 2015-03-03T07:10:10.057

Sorry. It should have been i<20&&'|'. Does that work? – FUZxxl – 2015-03-03T11:41:36.327

Still not quite there unfortunately - since && is a logical operator I guess the result of the expression is either 1 or 0, not '|' or 0 as we would like it to be ? You can play with it here if you like...

– Paul R – 2015-03-03T12:05:10.373

1How about this to save two bytes in '|' printing? c;main(i){for(i=21;i--;c='|')printf("%*s%c\n",i/5*6+5,i%5?"":"_____",c);} – Runer112 – 2015-03-03T13:56:27.303

@Runer112: very devious - I like it - thanks ! – Paul R – 2015-03-03T16:56:06.603

11

Java, 198 158 156 146 bytes

This can probably be shortened a lot. As usual, suggestions are welcome.

void a(){String a="",b="_____",c=b;for(int i=-1;i<20;b=i%5<1?b.replace(c,"     "):i%5>3?b+" "+c:b)a=b+(++i>19?"":"|")+"\n"+a;System.out.print(a);}

Indented (kinda):

void a(){
    String a="",b="_____",c=b;
    for(int i=-1;i<20;b=i%5<1?b.replace(c,"     "):i%5>3?b+" "+c:b)
        a=b+(++i>19?"":"|")+"\n"+a;
    System.out.print(a);
}

Thanks Martin Büttner, Rainbolt, and Geobits.

TheNumberOne

Posted 2015-03-02T15:06:00.153

Reputation: 10 855

1Honestly, since you did it with Java, I'm impressed. – therewillbecoffee – 2015-03-02T16:57:08.450

9

Brainfuck (1065 Bytes)

It's not pretty, it's not short...but i'll optimize later on!

++++[->++++++++<]>........................
[->+++<]>-.....>++++++++++.[->+++<]>++....
...................-[->++++<]>.>++++++++++
.[->+++<]>++.......................-[->+++
+<]>.>++++++++++.[->+++<]>++..............
.........-[->++++<]>.>++++++++++.[->+++<]>
++.......................-[->++++<]>.>++++
++++++.[->+++<]>++..................[->+++
<]>-.....[->++++<]>.>++++++++++.[->+++<]>+
+.................-[->++++<]>.>++++++++++.
[->+++<]>++.................-[->++++<]>.>+
+++++++++.[->+++<]>++.................-[->
++++<]>.>++++++++++.[->+++<]>++...........
......-[->++++<]>.>++++++++++.[->+++<]>++.
...........[->+++<]>-.....[->++++<]>.>++++
++++++.[->+++<]>++...........-[->++++<]>.>
++++++++++.[->+++<]>++...........-[->++++<
]>.>++++++++++.[->+++<]>++...........-[->+
+++<]>.>++++++++++.[->+++<]>++...........-
[->++++<]>.>++++++++++.[->+++<]>++......[-
>+++<]>-.....[->++++<]>.>++++++++++.[->+++
<]>++.....-[->++++<]>.>++++++++++.[->+++<]
>++.....-[->++++<]>.>++++++++++.[->+++<]>+
+.....-[->++++<]>.>++++++++++.[->+++<]>++.
....-[->++++<]>.>++++++++++.[--->++<]>+++.
....[->++++<]>.

Joshpbarron

Posted 2015-03-02T15:06:00.153

Reputation: 787

brainfuck is never pretty :) upvote just for making it work – Purefan – 2015-03-03T09:13:17.897

http://ideone.com/ICtrhv Time limit exceeded I mean, what.... – therewillbecoffee – 2015-03-03T10:36:13.460

Bizzare...try it here: http://esoteric.sange.fi/brainfuck/impl/interp/i.html

– Joshpbarron – 2015-03-03T10:37:23.787

8

CJam, 36 30 bytes

Try it online.

L{{S5*\+}/S'|5*+]'_5*+}5*1>zN*

My initial 36-byte solution generated the result in the output orientation. Despite my attempts to squeeze more bytes out of the algorithm, I couldn't. Then I saw Martin's brilliant strategy of generating columns instead of rows and transposing the result. I realized that was probably a better approach, so I set off to create a transposition-based solution.

However, my approach to implementing that strategy varies quite a bit. Instead of generating full columns, I use an iterative solution that indents any already-generated "steps" and adds adds a new step at each iteration. So the first iteration of the main loop generates this:

 |||||
_
_
_
_
_

The second iteration of the main loop indents the existing step and adds a new one after it:

      |||||
     _
     _
     _
     _
     _
 |||||
_
_
_
_
_

And the full five iterations of the main loop generate this:

                     |||||
                    _
                    _
                    _
                    _
                    _
                |||||
               _
               _
               _
               _
               _
           |||||
          _
          _
          _
          _
          _
      |||||
     _
     _
     _
     _
     _
 |||||
_
_
_
_
_

After this, all that needs to be done is eliminate the first line, which would otherwise become the unwanted riser for the bottom step, and transpose.

Runer112

Posted 2015-03-02T15:06:00.153

Reputation: 3 636

7

Python 2, 80 77 74 bytes

n=24;exec"print' '*n+'_'*5+'|'*(n<24)+('\\n'+~-n*' '+'|')*4*(n>0);n-=6;"*5

Got rid of the double exec and fit everything into the one print!

Sp3000

Posted 2015-03-02T15:06:00.153

Reputation: 58 729

6

CJam, 36 32 bytes

{5*S*'_+a5*~_W<S+5'|*+}5/;]W%zN*

Test it here.

I also tried using an explicit formula, but it's longer in CJam... maybe it helps someone else:

21,29,ff{_2$5/)6*(=@@6/5*=_++" |_|"=}W%N*

Explanation

I found that the staircase can be built much more easily if you a) transpose the grid and b) reverse the lines:

_
_
_
_
_
 |||||
     _
     _
     _
     _
     _
      |||||
          _
          _
          _
          _
          _
           |||||
               _
               _
               _
               _
               _
                |||||
                    _
                    _
                    _
                    _
                    _

So first I'm building that, then reverse, then transpose.

{                     }5/        "For i in [0 .. 4].";
 5*S*'_+                         "Get a string of 5*i spaces and append _.";
        a5*~                     "Get five such lines.";
            _W<S+                "Duplicate the last, remove the _, add a space.";
                 5'|*+           "Add 5 copies of |.";
                         ;       "The above creates a row too many, so discard the last one.";
                          ]W%zN* "Wrap everything in an array, reverse, transpose, riffle
                                  with newlines.";

Martin Ender

Posted 2015-03-02T15:06:00.153

Reputation: 184 808

Okay, someone's did it with 30 bytes. – therewillbecoffee – 2015-03-03T10:26:37.987

6

Clip, 46

{:24S:5'_m[z{*4,:+5*6zS"|
":*6zS:5'_"|
"`}vR4`

Explanation

{               .- Put everything in a list -.
 :24S           .- 24 spaces                -.
 :5'_           .- 5 underscores            -.
 m[z            .- Map...                   -.
    {           .- A list                   -.
     *4         .- 4 of the following       -.
       ,        .- Append                   -.
        :+5*6zS .- 5 + 6 * the iteration of spaces  -.
        "|      .- A pipe and newline       -.
"
     :*6zS      .- 6 * the iteration of spaces      -.
     :5'_       .- 5 underscores            -.
     "|         .- A pipe and newline       -.
"
    `           .- End list (per iteration  -.
   }vR4         .- The mapping is onto {3,2,1,0}    -.

Ypnypn

Posted 2015-03-02T15:06:00.153

Reputation: 10 485

1Clip doesn't even have a Wikipedia page. I mean, what.... – therewillbecoffee – 2015-03-02T17:56:07.357

4@therewillbecoffee Many languages on this site don't have a Wikipedia page. That's the fun ;) – Ypnypn – 2015-03-02T18:07:22.630

@Ypnypn Did you design it? It looks really interesting! Although I'd be interested in a true quine. ;) (That one on the examples page is a bit cheaty.) – Martin Ender – 2015-03-02T18:11:22.810

6

ECMAScript 6, 142 138 129 91 bytes

Special thanks to @edc65 for really reworking this.

a=o='',[for(x of!0+o)(o=(a+'     |\n').repeat(4)+a+'_____|\n'+o,a+='      ')],a+'_____\n'+o

out.value=(a=o='',[for(x of!0+o)(o=(a+'     |\n').repeat(4)+a+'_____|\n'+o,a+='      ')],a+'_____\n'+o)
textarea{
  width:300px;
  height:400px;
}
<textarea id="out";></textarea>

The logic of the original version check @edc65 comment for how it morphed.

((f,l,p)=>                  //variables
f(24)+l+p[1]+               //add the non pattern line
[0,1,2,3].map(b=>f(18-6*b)) //add the right number of spaces in front of the 4 steps
.map((a,b)=>f(4,a+f(5)+p)   //the four repeating lines of the step 
+a+l)                       //the landing line
.join(p)+p)                 //put it all together
((n,s=' ')=>s.repeat(n)     //create an variable array of some character
,'_____','|\n')             //string literals

qw3n

Posted 2015-03-02T15:06:00.153

Reputation: 733

1You can safely remove the new constructor before Array to save a few bytes. – NinjaBearMonkey – 2015-03-03T00:50:30.600

@hsl thanks for some reason I thought the new was necessary. – qw3n – 2015-03-03T02:59:32.690

1Array(n).join(s) is so ES5! did you try repeat – edc65 – 2015-03-03T07:31:11.937

[1,2,3,4].map((a,b) and using just b => [0,1,2,3].map(b (-4) – edc65 – 2015-03-03T07:36:05.497

I run Firefox and it works, pretty nicely! – therewillbecoffee – 2015-03-03T10:23:18.290

@edc65 I'll have to remember the repeat function I hadn't seen it yet. – qw3n – 2015-03-03T14:04:36.483

Just for fun, some golfing advice - http://jsfiddle.net/90zp3729/1/ - score 95

– edc65 – 2015-03-04T09:18:14.860

@edc65 I added one really dirty hack to your for of loop. !0+o convert a number to a boolean then to a string. – qw3n – 2015-03-04T15:16:26.453

6

Python 2, 59

n=21
exec"n-=1;print n/5*6*' '+' _'[n%5<1]*5+'|'*(n<20);"*n

The 21 lines are indexed by n in [20,19,...,1,0]. First prints 6 spaces for each "step" we're up (minus 1), computed as n/5*6. Then, prints five spaces, except these are instead underscores for multiples of five. Finally, prints a vertical line, except for the top line n=20.

xnor

Posted 2015-03-02T15:06:00.153

Reputation: 115 687

Nice and straightforward. I like it! – Sp3000 – 2015-03-03T02:37:56.637

6

JavaScript, 115 107 96 94 89 87 83 bytes

This is too long to win, but it's the first time I've come up with an answer on PCG.SE, and I'm kind of proud to have made something postable.

With some helpful syntactical advice I shortened the code significantly - even below the scrollbar threshold!

for(s='',y=22;--y;s+='\n')for(x=0;++x<29;)s+=6*~(~-y/5)-~x?4+5*~(x/6)+y?' ':'_':'|'

vvye

Posted 2015-03-02T15:06:00.153

Reputation: 261

Nice answer, several things you could do to shorten it are take out the alert. If you run it in the console it works just fine without it. Also, the semicolon inside the last curly brace isn't necessary. You can save 1 byte by using (y/5-.2) instead of ((y-1)/5) – qw3n – 2015-03-03T16:33:27.390

@qw3n thanks for those suggestions; I wasn't sure if the alert was required by the rules. – vvye – 2015-03-03T19:31:59.780

You could also move the s+='\n' after the y-- and get rid of the curly braces so it looks like for(s='',y=21;y>0;y--,s+='\n'). I also initialized the s inside the for loop so your code is all one statement – qw3n – 2015-03-03T19:39:25.387

Sorry, one last thing you can do is move the the counting up and down of x and y into the conditional part of the loop it would look like this for(s='',y=22;--y;s+='\n')for(x=0;++x<29;)s+=x==6*~~(y/5-.2)+5?'|':y==5*~~(x/6)+1?'_':' ' – qw3n – 2015-03-03T19:54:02.030

@qw3n I was just about to change y>0 to y, but your solution goes even further. Thanks a lot for the help! – vvye – 2015-03-03T20:02:37.990

1I thought that was my last one but this should be it for me for(s='',y=22;--y;s+='\n')for(x=0;++x<29;)s+=6*~~(y/5-.2)+5-x?5*~~(x/6)+1-y?' ':'_':'|' if you flip your ternary expression you can test for number - x which is 0 if both terms are equal saving you 2 more bytes. – qw3n – 2015-03-03T21:04:01.723

1Tilde games: ~n == -n-1, -~n == n+1, ~-n == n-1, for(s='',y=22;--y;s+='\n')for(x=0;++x<29;)s+=6*~(~-y/5)-~x?4+5*~(x/6)+y?' ':'_':'|' is 83 – edc65 – 2015-03-04T09:37:41.973

You guys are amazing. – vvye – 2015-03-04T09:43:23.920

5

MATLAB, 68 bytes

I have the strong feeling MATLAB should be able to do better, but I can't think of a way.

p(1:5,6)='|';p(1,1:5)=95;w=blkdiag(p,p,p,p);w(21,25:29)=95;flipud(w)

Creates the stairs upside-down and flips it. My thaumometer broke because of all the magic constants around.

'|' is intentionally left as-is (instead of ascii codepoint) to initialize p and w as a char array.

Sanchises

Posted 2015-03-02T15:06:00.153

Reputation: 8 530

1'|' = 124 anyway, so that doesn't cost any extra chars. – Peter Cordes – 2015-03-03T06:42:01.607

5

Ruby, 48

25.times{|i|puts" "*(4-i/6)*5+(i%6==0??_*5:?|)}

Old approach, 68

4.times{|i|(?_*5+"
|"*5).each_line{|l|puts" "*(4-i)*5+l}}
puts"_"*5

psycotica0

Posted 2015-03-02T15:06:00.153

Reputation: 151

Welcome to PPCG! A couple of Ruby golfing tips: 1. there's some unnecessary whitespace in there. 2. Single character strings like '_' can be written as ?_. 3. Newlines can be embedded directly in strings (so you can actually do "<linebreakhere>|"). 4. The parentheses around that aren't necessary. The final puts can be replaced with $><< (which allows you to get rid of the space, even after using ?_). Keep it up! :) – Martin Ender – 2015-03-03T13:16:50.353

Yeah, I just got rid of some whitespace. Thanks! I didn't know about the single character strings. – psycotica0 – 2015-03-03T13:19:02.990

You can probably also replace (1..4).map by 4.times and then use 4-i instead of 5-i. – Martin Ender – 2015-03-03T13:26:22.790

Ooh, good call. Done. – psycotica0 – 2015-03-03T13:29:45.740

4

Julia, 83 bytes

for n=24:-6:0 print(" "^n*"_"^5*"|"^(n<24)*"\n"*(" "^(n>0?n-1:0)*"|\n"^(n>0))^4)end

In Julia, string concatenation is performed using the * operator and string repetition is performed using ^.

Alex A.

Posted 2015-03-02T15:06:00.153

Reputation: 23 761

4

><>, 108 104 100 bytes

cc+::?v~'_____'o\/' 'o  \
?:o'|'\' 'o1-30.o\v!?:-1<}:{oav!?:<4;!
-20.12^?(+cc:ooo/ \~1-'!|'o1. \~ao6

A simple ><> solution, using the same strategy as my Python answer. The main difference is that ><> doesn't have string multiplication (or even strings), so all of that is done with loops.

Explanation

cc+                  Push 24 (call this "n")

[outer loop]
[loop 1, print n spaces]

:                    Copy n (call this "i")
:?                   If i is not zero...
' 'o1-30.                Print space, decrement i and go to start of loop 1

~'_____'ooooo        Pop i and print five underscores
:cc+(?               If n < 24...
'|'o                     Print a pipe
21.                  Otherwise skip pipe printing

[loop 2: print vertical parts of stairs]

?!;                  If n is zero, halt
4                    Push 4 (call this "j")
?!                   If j is zero...
~ao6-20.                 Pop j, print a newline, minus 6 from n and go to start of outer loop
ao                   Print a newline
}:{                  Copy n (call this "k")

[loop 3: print n-1 spaces]

1-                   Decrement k
:?!                  If k is zero...
    ~1-'!|'o1.           Pop k, decrement j, print a pipe and go to start of loop 2
' 'o                 Otherwise print a space and go to start of loop 3

Sp3000

Posted 2015-03-02T15:06:00.153

Reputation: 58 729

I feel like I will always upvote a ><> answer. – krs013 – 2015-03-04T17:14:31.143

3

Groovy, 98 71 bytes

// old: (25..5).each{i->println((1..(i-(i-1)%5)).collect{' '}.join()+(i%5?'|':('_____'+(i==25?'':'|'))))}

(25..5).each{i->println(' '*(i-(i-1)%5)+(i%5?'|':'_'*5+(i%25?'|':'')))}

(25..5).each { i ->
    println(
        ' '*(i - (i - 1) % 5) + (
            i % 5 ? 
            '|' : 
            '_'*5 + (i % 25 ? '|' : '')
        )
    )
}    

I'm pretty sure, that it can be reduced somehow :) shortened by @Score_Under

Kamil Mikolajczyk

Posted 2015-03-02T15:06:00.153

Reputation: 181

1I have a few bytes to shave: Replace the collect/join with a multiply: ' '*(i-(i-1)%5), remove brackets from around ('_____'+(i==25?'':'|')), replace the '_____' with '_'*5, and if you flip the last conditional you can use % as an unorthodox inequality operator: (i%25?'|':''). This should get you down to 71. – Score_Under – 2015-03-05T03:42:59.677

@Score_Under nice, thanks, I didn't know about multiplying strings :D – Kamil Mikolajczyk – 2015-03-05T10:13:35.647

2

Perl, 50

#!perl -l
print$"x6x(-$_/5),($_%5?$":_)x5,"|"x$|++for-20..0

Try me.

nutki

Posted 2015-03-02T15:06:00.153

Reputation: 3 634

2

Visual FoxPro 9.0, 261 bytes

n = Number of Steps

total of 175 characters, but had to output to file to display correctly - so minus 43 chars for file operations = 132 chars.

n=10
c=CHR(13)
f="st.t"
ERAS (f)    
FOR i=n TO 1 STEP -1
    p=(i-1)*6
    =STRTO(PADL("_____",p+5)+IIF(i<n,"|","")+c+IIF(i>1,REPLI(PADL("|"+c,p+1),4),""),f,.t.)
    ?PADL("_____",p+5)+IIF(i<n,"|","")+c+IIF(i>1,REPLI(PADL("|"+c,p+1),4),"")
ENDFOR
MODI COMM (f)

Note to answerer: Byte count is for the absolute working source code, and the byte counter says that it's 261 bytes, so it is.

danr44z

Posted 2015-03-02T15:06:00.153

Reputation: 21

2

T-SQL, 276 bytes

declare @x int declare @y int declare @w varchar(30) declare @l char(5) set @l='_____' set @x=23 while @x > 4 begin set @w=replicate(' ',@x) set @y=0 if @x=23 print @w+' '+@l else print @w+' '+@l+'|' while @y < 4 begin set @y=1+@y print @w+'|' end set @x=@x-6 end print @l+'|'

J.r. Nipok

Posted 2015-03-02T15:06:00.153

Reputation: 21

2

Bash (+tac from coreutils): 110 bytes

This can be pasted directly into the terminal.

(n=;set {1..4};for i do echo "${n}_____|";n+='     ';for i do echo "$n|";done;n+=\ ;done;echo "${n}_____")|tac

Score_Under

Posted 2015-03-02T15:06:00.153

Reputation: 271

Without |tac, it doesn't quite work. And I ran this on Git Bash, so I should kill myself. – therewillbecoffee – 2015-03-05T04:42:04.203

1

x86 machine code, 48 bytes

B1 05 B4 0E 80 E9 01 B0 5F B5 05 80 ED 01 CD 10 80 FD 00 75 F6 B5 05 80 ED 01 B0 0A CD 10 B0 08 CD 10 B0 7C CD 10 80 FD 00 75 EC 80 F9 00 75 D4

Assembly code equivalent:

mov cl, 5
mov ah, 0Eh
main:
    sub cl, 1

print_step:
    mov al, '_'
    mov ch, 5

.loop:
    sub ch, 1

    int 10h

    cmp ch, 0
    jne .loop

print_stoop:
    mov ch, 5

.loop:
    sub ch, 1

    mov al, 0Ah;    ascii newline
    int 10h

    mov al, 8;      ascii backspace
    int 10h

    mov al, '|'
    int 10h

    cmp ch, 0
    jne .loop

cmp cl, 0
jne main

Output:

_____
    |
    |
    |
    |
    |_____
         |
         |
         |
         |
         |_____
              |
              |
              |
              |
              |_____
                   |
                   |
                   |
                   |
                   |_____
                        |
                        |
                        |
                        |
                        |

Sorry about the output being different; I hope it is acceptable.

This was run in DOSBOX

SirPython

Posted 2015-03-02T15:06:00.153

Reputation: 178