Draw some expanding arrows











up vote
14
down vote

favorite
3












This challenge is about printing a series of growing ASCII-art arrows. I'll describe the pattern in words, but it might be easier to look at what the start of this series looks like:



>
<
->
<-
-->
<--
--->
<---
---->
<----
----->
<-----
------>
<------
...


An arrow with length n contains an arrowhead (< or >) and n-1 dashes (-). A right-facing arrow has the dashes first, then a >. A left-facing arrow starts with <, and is followed by the dashes. The series consists of a length n right-facing arrow followed by a length n left-facing arrow, with n from 1 to infinity.



To complete the challenge, write a program or function that takes one input, an integer i >= 1, and outputs the first i arrows. Arrows are individual, not in right-left pairs, so for i=3 you should output:



>
<
->


You can return a list of strings, or print them one after the other. If printing, the arrows must be delimited by some consistent delimiter, which doesn't have to be a newline as in the example.



This is code-golf, so fewest bytes wins.










share|improve this question


















  • 1




    Related.
    – AdmBorkBork
    10 hours ago










  • Can we have spaces before/after each line?
    – Olivier Grégoire
    10 hours ago










  • @OlivierGrégoire Yes, trailing whitespace is ok.
    – Pavel
    10 hours ago










  • And heading whitespace?
    – Olivier Grégoire
    10 hours ago










  • @OlivierGrégoire Yeah, that's fine.
    – Pavel
    10 hours ago

















up vote
14
down vote

favorite
3












This challenge is about printing a series of growing ASCII-art arrows. I'll describe the pattern in words, but it might be easier to look at what the start of this series looks like:



>
<
->
<-
-->
<--
--->
<---
---->
<----
----->
<-----
------>
<------
...


An arrow with length n contains an arrowhead (< or >) and n-1 dashes (-). A right-facing arrow has the dashes first, then a >. A left-facing arrow starts with <, and is followed by the dashes. The series consists of a length n right-facing arrow followed by a length n left-facing arrow, with n from 1 to infinity.



To complete the challenge, write a program or function that takes one input, an integer i >= 1, and outputs the first i arrows. Arrows are individual, not in right-left pairs, so for i=3 you should output:



>
<
->


You can return a list of strings, or print them one after the other. If printing, the arrows must be delimited by some consistent delimiter, which doesn't have to be a newline as in the example.



This is code-golf, so fewest bytes wins.










share|improve this question


















  • 1




    Related.
    – AdmBorkBork
    10 hours ago










  • Can we have spaces before/after each line?
    – Olivier Grégoire
    10 hours ago










  • @OlivierGrégoire Yes, trailing whitespace is ok.
    – Pavel
    10 hours ago










  • And heading whitespace?
    – Olivier Grégoire
    10 hours ago










  • @OlivierGrégoire Yeah, that's fine.
    – Pavel
    10 hours ago















up vote
14
down vote

favorite
3









up vote
14
down vote

favorite
3






3





This challenge is about printing a series of growing ASCII-art arrows. I'll describe the pattern in words, but it might be easier to look at what the start of this series looks like:



>
<
->
<-
-->
<--
--->
<---
---->
<----
----->
<-----
------>
<------
...


An arrow with length n contains an arrowhead (< or >) and n-1 dashes (-). A right-facing arrow has the dashes first, then a >. A left-facing arrow starts with <, and is followed by the dashes. The series consists of a length n right-facing arrow followed by a length n left-facing arrow, with n from 1 to infinity.



To complete the challenge, write a program or function that takes one input, an integer i >= 1, and outputs the first i arrows. Arrows are individual, not in right-left pairs, so for i=3 you should output:



>
<
->


You can return a list of strings, or print them one after the other. If printing, the arrows must be delimited by some consistent delimiter, which doesn't have to be a newline as in the example.



This is code-golf, so fewest bytes wins.










share|improve this question













This challenge is about printing a series of growing ASCII-art arrows. I'll describe the pattern in words, but it might be easier to look at what the start of this series looks like:



>
<
->
<-
-->
<--
--->
<---
---->
<----
----->
<-----
------>
<------
...


An arrow with length n contains an arrowhead (< or >) and n-1 dashes (-). A right-facing arrow has the dashes first, then a >. A left-facing arrow starts with <, and is followed by the dashes. The series consists of a length n right-facing arrow followed by a length n left-facing arrow, with n from 1 to infinity.



To complete the challenge, write a program or function that takes one input, an integer i >= 1, and outputs the first i arrows. Arrows are individual, not in right-left pairs, so for i=3 you should output:



>
<
->


You can return a list of strings, or print them one after the other. If printing, the arrows must be delimited by some consistent delimiter, which doesn't have to be a newline as in the example.



This is code-golf, so fewest bytes wins.







code-golf ascii-art sequence






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked 11 hours ago









Pavel

4,76313288




4,76313288








  • 1




    Related.
    – AdmBorkBork
    10 hours ago










  • Can we have spaces before/after each line?
    – Olivier Grégoire
    10 hours ago










  • @OlivierGrégoire Yes, trailing whitespace is ok.
    – Pavel
    10 hours ago










  • And heading whitespace?
    – Olivier Grégoire
    10 hours ago










  • @OlivierGrégoire Yeah, that's fine.
    – Pavel
    10 hours ago
















  • 1




    Related.
    – AdmBorkBork
    10 hours ago










  • Can we have spaces before/after each line?
    – Olivier Grégoire
    10 hours ago










  • @OlivierGrégoire Yes, trailing whitespace is ok.
    – Pavel
    10 hours ago










  • And heading whitespace?
    – Olivier Grégoire
    10 hours ago










  • @OlivierGrégoire Yeah, that's fine.
    – Pavel
    10 hours ago










1




1




Related.
– AdmBorkBork
10 hours ago




Related.
– AdmBorkBork
10 hours ago












Can we have spaces before/after each line?
– Olivier Grégoire
10 hours ago




Can we have spaces before/after each line?
– Olivier Grégoire
10 hours ago












@OlivierGrégoire Yes, trailing whitespace is ok.
– Pavel
10 hours ago




@OlivierGrégoire Yes, trailing whitespace is ok.
– Pavel
10 hours ago












And heading whitespace?
– Olivier Grégoire
10 hours ago




And heading whitespace?
– Olivier Grégoire
10 hours ago












@OlivierGrégoire Yeah, that's fine.
– Pavel
10 hours ago






@OlivierGrégoire Yeah, that's fine.
– Pavel
10 hours ago












23 Answers
23






active

oldest

votes

















up vote
6
down vote














R, 69 bytes





for(i in 1:scan()-1)cat('<'[i%%2],rep('-',i/2),'>'[!i%%2],'
',sep='')


Try it online!




  • -5 bytes thanks to @Giuseppe

  • -3 bytes thanks to @Robert S.






share|improve this answer























  • strrep coerces its second argument to integer so you can use / in place of %/%
    – Giuseppe
    10 hours ago










  • you can also get rid of a entirely by indexing over 0...(n-1) instead: Try it online!
    – Giuseppe
    10 hours ago










  • I'm an idiot... thanks ! :D
    – digEmAll
    9 hours ago










  • @Giuseppe :also I just noticed the deleted question of Robert S. I can use rep instead of strrep and save 3 bytes...(facepalm)
    – digEmAll
    9 hours ago


















up vote
4
down vote














Canvas, 10 bytes



⇵-×<n¹[↔}]


Try it here!






share|improve this answer





















  • I don't know any Canvas, but is that an arrow-drawing builtin I see? kinda looks like it!
    – Pavel
    11 hours ago










  • is the "reverse horizontally" built-in (also swapping > & <), sadly no arrow built-ins :p
    – dzaima
    11 hours ago


















up vote
4
down vote














Python 2, 53 bytes





k=-1
exec"print'<'[k%2:]+'-'*k+k%2*'>';k+=1;"*input()


Try it online!






share|improve this answer





















  • Your arrows have too many dashes; only every other one should lengthen by a dash.
    – xnor
    33 mins ago


















up vote
3
down vote













Pyth, 17 bytes



m_W%d2+*-/d2@"><


Output is a list of strings. Try it online here.



m_W%d2+*-/d2@"><"dQ   Implicit: Q=eval(input())
Trailing "dQ inferred
m Q Map [0-Q), as d, using:
/d2 Floored division of d by 2
*- Repeat "-" the above number of times
+ Append to the above...
@"><"d Modular index d into "><" - yields ">" for even d, "<" for odd
- examples: d=4 gives "-->", d=7 gives "---<"
_W Reverse the above if...
%d2 ... (d % 2) != 0
Implicit print result of the map





share|improve this answer




























    up vote
    3
    down vote














    Commodore BASIC V2 (C64), 94 bytes



    0inputn:fOi=1ton:oniaN1gO1:?"<";
    1on-(i<3)gO2:fOj=1.5toi/2:?"-";:nE
    2on-nOiaN1gO3:?">";
    3?:nE


    Not entirely sure about the byte count, this is based on the text representation for typing the valid program. It's a bit shorter on disk (91 bytes) because BASIC V2 uses a "tokenized" representation of programs.



    Online Demo



    Slightly "ungolfed":



    0 inputn:fori=1ton:oniand1goto1:print"<";    :rem read n from user, loop to n, if odd skip "<"
    1 on-(i<3)goto2:forj=1.5toi/2:print"-";:next :rem skip for i<3, print (i-1)/2 times "-"
    2 on-notiand1goto3:print">"; :rem if even skip ">"
    3 print:next :rem newline and next loop iteration





    share|improve this answer




























      up vote
      3
      down vote














      PowerShell, 62 56 50 bytes





      param($n)(0..$n|%{($j='-'*$_)+'>';"<$j"})[0..--$n]


      Try it online!



      Loops from 0 up to input $n, each iteration creating two arrow strings. Those are then indexed with 0..--$n to pull out the correct number of elements.



      Saved 6 bytes thanks to KGlasier.






      share|improve this answer























      • Messing around with my own solution I found a way to cut a few bytes on yours: Can save 4 bytes by wrapping the loop in brackets and indexing directly. ie param($n)(0..$n|%{($j='-'*$_++)+'>';"<$j"})[0..--$n]. So now you don't have to write $x twice.
        – KGlasier
        10 hours ago










      • Also you can save two more bytes by not using ++ in ($j='-'*$_++) as you don't use $_ anywhere else.
        – KGlasier
        10 hours ago








      • 1




        @KGlasier Awesome - thanks for the obvious golfs! :)
        – AdmBorkBork
        9 hours ago


















      up vote
      3
      down vote














      Jelly, 15 bytes



      ị⁾><;’H”-ẋƲṚ⁸¡)


      Try it online!






      share|improve this answer




























        up vote
        2
        down vote














        Java (JDK), 81 bytes





        n->{for(int i=0;i<n;)System.out.printf(i%2<1?"<%s%n":"%s>%n","-".repeat(i++/2));}


        Try it online!



        Explanations



        n->{                  // int-accepting consumer
        for(int i=0;i<n;) // for each i from 0 to n-1 included
        System.out.printf( // output on stdout with a pattern
        i%2<1 // if i is even:
        ?"<%s%n" // use the left-arrow pattern
        :"%s>%n", // else: use the right-arrow pattern
        "-".repeat(i++/2) // fill the pattern with i/2 dashes, and increment i
        ); //
        } //





        share|improve this answer






























          up vote
          2
          down vote














          SNOBOL4 (CSNOBOL4), 123 122 118 bytes



          	N =INPUT - 1
          P H =X / 2
          Y =DUPL('-',H)
          OUTPUT =EQ(H,X - H) Y '>' :S(I)
          OUTPUT ='<' Y
          I X =LT(X,N) X + 1 :S(P)
          END


          Try it online!






          share|improve this answer






























            up vote
            2
            down vote














            V, 22 bytes



            i>
            <Àñäkjjé-já-ñÀGjdG


            Try it online!






            share|improve this answer

















            • 2




              This looks like some weird scandinavian language
              – Pavel
              9 hours ago


















            up vote
            2
            down vote














            Charcoal, 16 bytes



            NθFθ«⊘ι↓>‖T»Fθ‖T


            Try it online! Link is to verbose version of code. I had three 17-byte solutions before I eventually stumbled over this one. Explanation:



            Nθ


            Input n.



            Fθ«


            Repeat n times, 0-indexed.



            ⊘ι


            Draw a line of -s of length half the index (truncated).



            ↓>


            Draw the arrowhead and move to the next line.



            ‖T»


            Reflect everything, flipping the arrowheads.



            Fθ‖T


            The above loop has n reflections, but we need an even number of reflections, so perform another n reflections.






            share|improve this answer




























              up vote
              2
              down vote














              Japt -m, 16 bytes



              "<>"¬hUu Uz ç-)q


              Try it online!



              Updated with a completely new method.



              Explanation:



                                  #Implicitly map over the range [0..input) as U
              "<>" #The string "<>"
              ¬ #Split into the array ["<",">"]
              hUu ) #Replace the element at index U modulo 2 with:
              - # The character '-'
              ç # Repeated a number of times equal to
              Uz # U integer divided by 2
              q #Join the array to a string





              share|improve this answer



















              • 1




                ç auto-casts its first parameter into a string, so you can drop the '.
                – Oliver
                2 hours ago


















              up vote
              1
              down vote













              JavaScript (ES6), 58 bytes



              Returns a space-separated string.





              n=>(g=p=>n--?k++&1?`<${p} `+g(p+'-'):p+'> '+g(p):'')(k='')


              Try it online!






              share|improve this answer




























                up vote
                1
                down vote














                Haskell, 51 bytes





                (`take`do b<-['-'<$[1..n]|n<-[0..]];[b++">",'<':b])


                Try it online!



                Explanation / Ungolfed



                Using do-notation saves us a concat, using '-'<$[1..n] is shorter than replicate, and finally using infix-notation allows a pointfree function with take, undoing these would give:



                f n = take n $ concat [ [b++">", '<':b] | n<-[0..], let b = replicate n '-' ]





                share|improve this answer






























                  up vote
                  1
                  down vote













                  Haskell, 41 bytes



                  (`take`g"")
                  g p=(p++">"):('<':p):g('-':p)


                  Try it online!



                  Plain old recursion: start with an emtpy string p, collect p with a right arrow, a left arrow with p and a recursive call with p one - longer. Take the first n items of this list.






                  share|improve this answer






























                    up vote
                    1
                    down vote













                    Powershell, 51 bytes





                    param($n)0..$n|%{'-'*$_+'>';'<'+'-'*$_}|?{$n---gt0}





                    share|improve this answer




























                      up vote
                      1
                      down vote














                      05AB1E, 23 bytes



                      FN2%D"><"è'-N2÷∍«s_iR},


                      Try it online!



                      First time using 05AB1E or any other golfing language for that matter. Any ideas welcome.






                      share|improve this answer




























                        up vote
                        1
                        down vote













                        Java 123 bytes



                        n->{String l="",r="";for(int c=0;c<n;c++)System.out.println(c%2==0?r=c==0?">":c==1?"<":"-"+r:(l+=c==0?">":c==1?"<":"-"));}





                        share|improve this answer




























                          up vote
                          1
                          down vote














                          Clean, 76 73 bytes



                          import StdEnv,StdLib
                          $n=take n[s\i<-inits['--'..],s<-[i++['>'],['<':i]]]


                          Try it online!



                          Uses the neat fact that ['-','-'..] is the same as ['--'..] to save a bit.






                          share|improve this answer




























                            up vote
                            1
                            down vote














                            6502 machine code (C64), 49 bytes



                            00 C0 20 9B B7 A2 00 8A 4A A8 90 05 A9 3C 20 D2 FF A9 2D C0 00 F0 06 20 D2 FF 
                            88 D0 FA 8A 4A B0 05 A9 3E 20 D2 FF A9 0D 20 D2 FF E8 E4 65 D0 D7 60


                            Still quite a bit shorter than BASIC ;) This one has a number range only up to 255 because the natural integer size of the machine has only 8 bits.



                            Online demo



                            Usage: SYS49152,[n] (e.g. SYS49152,3 for the example from the challenge)



                            Commented disassembly:



                                     00 C0       .WORD $C000        ; load address
                            .C:c000 20 9B B7 JSR $B79B ; get unsigned byte from commandline
                            .C:c003 A2 00 LDX #$00 ; main loop counter
                            .C:c005 .loop:
                            .C:c005 8A TXA ; loop counter to accumulator
                            .C:c006 4A LSR A ; divide by 2, shift lowest bit to C
                            .C:c007 A8 TAY ; result to Y
                            .C:c008 90 05 BCC .toright ; C clear -> counter even, skip '<'
                            .C:c00a A9 3C LDA #$3C ; load character '<'
                            .C:c00c 20 D2 FF JSR $FFD2 ; output character
                            .C:c00f .toright:
                            .C:c00f A9 2D LDA #$2D ; load character '-'
                            .C:c011 C0 00 CPY #$00 ; counter/2 == 0 ? then no dashes
                            .C:c013 F0 06 BEQ .skipdashes
                            .C:c015 .printdashes:
                            .C:c015 20 D2 FF JSR $FFD2 ; output character
                            .C:c018 88 DEY ; decrement Y
                            .C:c019 D0 FA BNE .printdashes ; not 0 yet -> repeat
                            .C:c01b .skipdashes:
                            .C:c01b 8A TXA ; loop counter to accumulator
                            .C:c01c 4A LSR A ; shift lowest bit to C
                            .C:c01d B0 05 BCS .toleft ; C set -> counter odd, skip '>'
                            .C:c01f A9 3E LDA #$3E ; load character '>'
                            .C:c021 20 D2 FF JSR $FFD2 ; output character
                            .C:c024 .toleft:
                            .C:c024 A9 0D LDA #$0D ; load newline character
                            .C:c026 20 D2 FF JSR $FFD2 ; output character
                            .C:c029 E8 INX ; next loop iteration
                            .C:c02a E4 65 CPX $65 ; compare to command line argument
                            .C:c02c D0 D7 BNE .loop ; not reached yet -> repeat main loop
                            .C:c02e 60 RTS ; exit





                            share|improve this answer




























                              up vote
                              1
                              down vote














                              Perl 5, 44 bytes





                              map{$_/=2;say'<'x/./,'-'x$_,'>'x!$&}0..<>-1


                              Try it online!






                              share|improve this answer




























                                up vote
                                1
                                down vote













                                Japt -m, 16 15 13 bytes



                                g"><" iUUz ç-


                                Test it online






                                share|improve this answer






























                                  up vote
                                  0
                                  down vote














                                  Perl 6, 39 bytes





                                  {map {'<'x$_%2~'-'x$_/2~'>'x$_%%2},^$_}


                                  Try it online!



                                  Anonymous code block that returns a list of lines.






                                  share|improve this answer





















                                    Your Answer





                                    StackExchange.ifUsing("editor", function () {
                                    return StackExchange.using("mathjaxEditing", function () {
                                    StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
                                    StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
                                    });
                                    });
                                    }, "mathjax-editing");

                                    StackExchange.ifUsing("editor", function () {
                                    StackExchange.using("externalEditor", function () {
                                    StackExchange.using("snippets", function () {
                                    StackExchange.snippets.init();
                                    });
                                    });
                                    }, "code-snippets");

                                    StackExchange.ready(function() {
                                    var channelOptions = {
                                    tags: "".split(" "),
                                    id: "200"
                                    };
                                    initTagRenderer("".split(" "), "".split(" "), channelOptions);

                                    StackExchange.using("externalEditor", function() {
                                    // Have to fire editor after snippets, if snippets enabled
                                    if (StackExchange.settings.snippets.snippetsEnabled) {
                                    StackExchange.using("snippets", function() {
                                    createEditor();
                                    });
                                    }
                                    else {
                                    createEditor();
                                    }
                                    });

                                    function createEditor() {
                                    StackExchange.prepareEditor({
                                    heartbeatType: 'answer',
                                    convertImagesToLinks: false,
                                    noModals: true,
                                    showLowRepImageUploadWarning: true,
                                    reputationToPostImages: null,
                                    bindNavPrevention: true,
                                    postfix: "",
                                    imageUploader: {
                                    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
                                    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
                                    allowUrls: true
                                    },
                                    onDemand: true,
                                    discardSelector: ".discard-answer"
                                    ,immediatelyShowMarkdownHelp:true
                                    });


                                    }
                                    });














                                    draft saved

                                    draft discarded


















                                    StackExchange.ready(
                                    function () {
                                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f177454%2fdraw-some-expanding-arrows%23new-answer', 'question_page');
                                    }
                                    );

                                    Post as a guest















                                    Required, but never shown

























                                    23 Answers
                                    23






                                    active

                                    oldest

                                    votes








                                    23 Answers
                                    23






                                    active

                                    oldest

                                    votes









                                    active

                                    oldest

                                    votes






                                    active

                                    oldest

                                    votes








                                    up vote
                                    6
                                    down vote














                                    R, 69 bytes





                                    for(i in 1:scan()-1)cat('<'[i%%2],rep('-',i/2),'>'[!i%%2],'
                                    ',sep='')


                                    Try it online!




                                    • -5 bytes thanks to @Giuseppe

                                    • -3 bytes thanks to @Robert S.






                                    share|improve this answer























                                    • strrep coerces its second argument to integer so you can use / in place of %/%
                                      – Giuseppe
                                      10 hours ago










                                    • you can also get rid of a entirely by indexing over 0...(n-1) instead: Try it online!
                                      – Giuseppe
                                      10 hours ago










                                    • I'm an idiot... thanks ! :D
                                      – digEmAll
                                      9 hours ago










                                    • @Giuseppe :also I just noticed the deleted question of Robert S. I can use rep instead of strrep and save 3 bytes...(facepalm)
                                      – digEmAll
                                      9 hours ago















                                    up vote
                                    6
                                    down vote














                                    R, 69 bytes





                                    for(i in 1:scan()-1)cat('<'[i%%2],rep('-',i/2),'>'[!i%%2],'
                                    ',sep='')


                                    Try it online!




                                    • -5 bytes thanks to @Giuseppe

                                    • -3 bytes thanks to @Robert S.






                                    share|improve this answer























                                    • strrep coerces its second argument to integer so you can use / in place of %/%
                                      – Giuseppe
                                      10 hours ago










                                    • you can also get rid of a entirely by indexing over 0...(n-1) instead: Try it online!
                                      – Giuseppe
                                      10 hours ago










                                    • I'm an idiot... thanks ! :D
                                      – digEmAll
                                      9 hours ago










                                    • @Giuseppe :also I just noticed the deleted question of Robert S. I can use rep instead of strrep and save 3 bytes...(facepalm)
                                      – digEmAll
                                      9 hours ago













                                    up vote
                                    6
                                    down vote










                                    up vote
                                    6
                                    down vote










                                    R, 69 bytes





                                    for(i in 1:scan()-1)cat('<'[i%%2],rep('-',i/2),'>'[!i%%2],'
                                    ',sep='')


                                    Try it online!




                                    • -5 bytes thanks to @Giuseppe

                                    • -3 bytes thanks to @Robert S.






                                    share|improve this answer















                                    R, 69 bytes





                                    for(i in 1:scan()-1)cat('<'[i%%2],rep('-',i/2),'>'[!i%%2],'
                                    ',sep='')


                                    Try it online!




                                    • -5 bytes thanks to @Giuseppe

                                    • -3 bytes thanks to @Robert S.







                                    share|improve this answer














                                    share|improve this answer



                                    share|improve this answer








                                    edited 9 hours ago

























                                    answered 10 hours ago









                                    digEmAll

                                    2,36148




                                    2,36148












                                    • strrep coerces its second argument to integer so you can use / in place of %/%
                                      – Giuseppe
                                      10 hours ago










                                    • you can also get rid of a entirely by indexing over 0...(n-1) instead: Try it online!
                                      – Giuseppe
                                      10 hours ago










                                    • I'm an idiot... thanks ! :D
                                      – digEmAll
                                      9 hours ago










                                    • @Giuseppe :also I just noticed the deleted question of Robert S. I can use rep instead of strrep and save 3 bytes...(facepalm)
                                      – digEmAll
                                      9 hours ago


















                                    • strrep coerces its second argument to integer so you can use / in place of %/%
                                      – Giuseppe
                                      10 hours ago










                                    • you can also get rid of a entirely by indexing over 0...(n-1) instead: Try it online!
                                      – Giuseppe
                                      10 hours ago










                                    • I'm an idiot... thanks ! :D
                                      – digEmAll
                                      9 hours ago










                                    • @Giuseppe :also I just noticed the deleted question of Robert S. I can use rep instead of strrep and save 3 bytes...(facepalm)
                                      – digEmAll
                                      9 hours ago
















                                    strrep coerces its second argument to integer so you can use / in place of %/%
                                    – Giuseppe
                                    10 hours ago




                                    strrep coerces its second argument to integer so you can use / in place of %/%
                                    – Giuseppe
                                    10 hours ago












                                    you can also get rid of a entirely by indexing over 0...(n-1) instead: Try it online!
                                    – Giuseppe
                                    10 hours ago




                                    you can also get rid of a entirely by indexing over 0...(n-1) instead: Try it online!
                                    – Giuseppe
                                    10 hours ago












                                    I'm an idiot... thanks ! :D
                                    – digEmAll
                                    9 hours ago




                                    I'm an idiot... thanks ! :D
                                    – digEmAll
                                    9 hours ago












                                    @Giuseppe :also I just noticed the deleted question of Robert S. I can use rep instead of strrep and save 3 bytes...(facepalm)
                                    – digEmAll
                                    9 hours ago




                                    @Giuseppe :also I just noticed the deleted question of Robert S. I can use rep instead of strrep and save 3 bytes...(facepalm)
                                    – digEmAll
                                    9 hours ago










                                    up vote
                                    4
                                    down vote














                                    Canvas, 10 bytes



                                    ⇵-×<n¹[↔}]


                                    Try it here!






                                    share|improve this answer





















                                    • I don't know any Canvas, but is that an arrow-drawing builtin I see? kinda looks like it!
                                      – Pavel
                                      11 hours ago










                                    • is the "reverse horizontally" built-in (also swapping > & <), sadly no arrow built-ins :p
                                      – dzaima
                                      11 hours ago















                                    up vote
                                    4
                                    down vote














                                    Canvas, 10 bytes



                                    ⇵-×<n¹[↔}]


                                    Try it here!






                                    share|improve this answer





















                                    • I don't know any Canvas, but is that an arrow-drawing builtin I see? kinda looks like it!
                                      – Pavel
                                      11 hours ago










                                    • is the "reverse horizontally" built-in (also swapping > & <), sadly no arrow built-ins :p
                                      – dzaima
                                      11 hours ago













                                    up vote
                                    4
                                    down vote










                                    up vote
                                    4
                                    down vote










                                    Canvas, 10 bytes



                                    ⇵-×<n¹[↔}]


                                    Try it here!






                                    share|improve this answer













                                    Canvas, 10 bytes



                                    ⇵-×<n¹[↔}]


                                    Try it here!







                                    share|improve this answer












                                    share|improve this answer



                                    share|improve this answer










                                    answered 11 hours ago









                                    dzaima

                                    14.3k21754




                                    14.3k21754












                                    • I don't know any Canvas, but is that an arrow-drawing builtin I see? kinda looks like it!
                                      – Pavel
                                      11 hours ago










                                    • is the "reverse horizontally" built-in (also swapping > & <), sadly no arrow built-ins :p
                                      – dzaima
                                      11 hours ago


















                                    • I don't know any Canvas, but is that an arrow-drawing builtin I see? kinda looks like it!
                                      – Pavel
                                      11 hours ago










                                    • is the "reverse horizontally" built-in (also swapping > & <), sadly no arrow built-ins :p
                                      – dzaima
                                      11 hours ago
















                                    I don't know any Canvas, but is that an arrow-drawing builtin I see? kinda looks like it!
                                    – Pavel
                                    11 hours ago




                                    I don't know any Canvas, but is that an arrow-drawing builtin I see? kinda looks like it!
                                    – Pavel
                                    11 hours ago












                                    is the "reverse horizontally" built-in (also swapping > & <), sadly no arrow built-ins :p
                                    – dzaima
                                    11 hours ago




                                    is the "reverse horizontally" built-in (also swapping > & <), sadly no arrow built-ins :p
                                    – dzaima
                                    11 hours ago










                                    up vote
                                    4
                                    down vote














                                    Python 2, 53 bytes





                                    k=-1
                                    exec"print'<'[k%2:]+'-'*k+k%2*'>';k+=1;"*input()


                                    Try it online!






                                    share|improve this answer





















                                    • Your arrows have too many dashes; only every other one should lengthen by a dash.
                                      – xnor
                                      33 mins ago















                                    up vote
                                    4
                                    down vote














                                    Python 2, 53 bytes





                                    k=-1
                                    exec"print'<'[k%2:]+'-'*k+k%2*'>';k+=1;"*input()


                                    Try it online!






                                    share|improve this answer





















                                    • Your arrows have too many dashes; only every other one should lengthen by a dash.
                                      – xnor
                                      33 mins ago













                                    up vote
                                    4
                                    down vote










                                    up vote
                                    4
                                    down vote










                                    Python 2, 53 bytes





                                    k=-1
                                    exec"print'<'[k%2:]+'-'*k+k%2*'>';k+=1;"*input()


                                    Try it online!






                                    share|improve this answer













                                    Python 2, 53 bytes





                                    k=-1
                                    exec"print'<'[k%2:]+'-'*k+k%2*'>';k+=1;"*input()


                                    Try it online!







                                    share|improve this answer












                                    share|improve this answer



                                    share|improve this answer










                                    answered 10 hours ago









                                    ovs

                                    18.6k21059




                                    18.6k21059












                                    • Your arrows have too many dashes; only every other one should lengthen by a dash.
                                      – xnor
                                      33 mins ago


















                                    • Your arrows have too many dashes; only every other one should lengthen by a dash.
                                      – xnor
                                      33 mins ago
















                                    Your arrows have too many dashes; only every other one should lengthen by a dash.
                                    – xnor
                                    33 mins ago




                                    Your arrows have too many dashes; only every other one should lengthen by a dash.
                                    – xnor
                                    33 mins ago










                                    up vote
                                    3
                                    down vote













                                    Pyth, 17 bytes



                                    m_W%d2+*-/d2@"><


                                    Output is a list of strings. Try it online here.



                                    m_W%d2+*-/d2@"><"dQ   Implicit: Q=eval(input())
                                    Trailing "dQ inferred
                                    m Q Map [0-Q), as d, using:
                                    /d2 Floored division of d by 2
                                    *- Repeat "-" the above number of times
                                    + Append to the above...
                                    @"><"d Modular index d into "><" - yields ">" for even d, "<" for odd
                                    - examples: d=4 gives "-->", d=7 gives "---<"
                                    _W Reverse the above if...
                                    %d2 ... (d % 2) != 0
                                    Implicit print result of the map





                                    share|improve this answer

























                                      up vote
                                      3
                                      down vote













                                      Pyth, 17 bytes



                                      m_W%d2+*-/d2@"><


                                      Output is a list of strings. Try it online here.



                                      m_W%d2+*-/d2@"><"dQ   Implicit: Q=eval(input())
                                      Trailing "dQ inferred
                                      m Q Map [0-Q), as d, using:
                                      /d2 Floored division of d by 2
                                      *- Repeat "-" the above number of times
                                      + Append to the above...
                                      @"><"d Modular index d into "><" - yields ">" for even d, "<" for odd
                                      - examples: d=4 gives "-->", d=7 gives "---<"
                                      _W Reverse the above if...
                                      %d2 ... (d % 2) != 0
                                      Implicit print result of the map





                                      share|improve this answer























                                        up vote
                                        3
                                        down vote










                                        up vote
                                        3
                                        down vote









                                        Pyth, 17 bytes



                                        m_W%d2+*-/d2@"><


                                        Output is a list of strings. Try it online here.



                                        m_W%d2+*-/d2@"><"dQ   Implicit: Q=eval(input())
                                        Trailing "dQ inferred
                                        m Q Map [0-Q), as d, using:
                                        /d2 Floored division of d by 2
                                        *- Repeat "-" the above number of times
                                        + Append to the above...
                                        @"><"d Modular index d into "><" - yields ">" for even d, "<" for odd
                                        - examples: d=4 gives "-->", d=7 gives "---<"
                                        _W Reverse the above if...
                                        %d2 ... (d % 2) != 0
                                        Implicit print result of the map





                                        share|improve this answer












                                        Pyth, 17 bytes



                                        m_W%d2+*-/d2@"><


                                        Output is a list of strings. Try it online here.



                                        m_W%d2+*-/d2@"><"dQ   Implicit: Q=eval(input())
                                        Trailing "dQ inferred
                                        m Q Map [0-Q), as d, using:
                                        /d2 Floored division of d by 2
                                        *- Repeat "-" the above number of times
                                        + Append to the above...
                                        @"><"d Modular index d into "><" - yields ">" for even d, "<" for odd
                                        - examples: d=4 gives "-->", d=7 gives "---<"
                                        _W Reverse the above if...
                                        %d2 ... (d % 2) != 0
                                        Implicit print result of the map






                                        share|improve this answer












                                        share|improve this answer



                                        share|improve this answer










                                        answered 10 hours ago









                                        Sok

                                        3,469722




                                        3,469722






















                                            up vote
                                            3
                                            down vote














                                            Commodore BASIC V2 (C64), 94 bytes



                                            0inputn:fOi=1ton:oniaN1gO1:?"<";
                                            1on-(i<3)gO2:fOj=1.5toi/2:?"-";:nE
                                            2on-nOiaN1gO3:?">";
                                            3?:nE


                                            Not entirely sure about the byte count, this is based on the text representation for typing the valid program. It's a bit shorter on disk (91 bytes) because BASIC V2 uses a "tokenized" representation of programs.



                                            Online Demo



                                            Slightly "ungolfed":



                                            0 inputn:fori=1ton:oniand1goto1:print"<";    :rem read n from user, loop to n, if odd skip "<"
                                            1 on-(i<3)goto2:forj=1.5toi/2:print"-";:next :rem skip for i<3, print (i-1)/2 times "-"
                                            2 on-notiand1goto3:print">"; :rem if even skip ">"
                                            3 print:next :rem newline and next loop iteration





                                            share|improve this answer

























                                              up vote
                                              3
                                              down vote














                                              Commodore BASIC V2 (C64), 94 bytes



                                              0inputn:fOi=1ton:oniaN1gO1:?"<";
                                              1on-(i<3)gO2:fOj=1.5toi/2:?"-";:nE
                                              2on-nOiaN1gO3:?">";
                                              3?:nE


                                              Not entirely sure about the byte count, this is based on the text representation for typing the valid program. It's a bit shorter on disk (91 bytes) because BASIC V2 uses a "tokenized" representation of programs.



                                              Online Demo



                                              Slightly "ungolfed":



                                              0 inputn:fori=1ton:oniand1goto1:print"<";    :rem read n from user, loop to n, if odd skip "<"
                                              1 on-(i<3)goto2:forj=1.5toi/2:print"-";:next :rem skip for i<3, print (i-1)/2 times "-"
                                              2 on-notiand1goto3:print">"; :rem if even skip ">"
                                              3 print:next :rem newline and next loop iteration





                                              share|improve this answer























                                                up vote
                                                3
                                                down vote










                                                up vote
                                                3
                                                down vote










                                                Commodore BASIC V2 (C64), 94 bytes



                                                0inputn:fOi=1ton:oniaN1gO1:?"<";
                                                1on-(i<3)gO2:fOj=1.5toi/2:?"-";:nE
                                                2on-nOiaN1gO3:?">";
                                                3?:nE


                                                Not entirely sure about the byte count, this is based on the text representation for typing the valid program. It's a bit shorter on disk (91 bytes) because BASIC V2 uses a "tokenized" representation of programs.



                                                Online Demo



                                                Slightly "ungolfed":



                                                0 inputn:fori=1ton:oniand1goto1:print"<";    :rem read n from user, loop to n, if odd skip "<"
                                                1 on-(i<3)goto2:forj=1.5toi/2:print"-";:next :rem skip for i<3, print (i-1)/2 times "-"
                                                2 on-notiand1goto3:print">"; :rem if even skip ">"
                                                3 print:next :rem newline and next loop iteration





                                                share|improve this answer













                                                Commodore BASIC V2 (C64), 94 bytes



                                                0inputn:fOi=1ton:oniaN1gO1:?"<";
                                                1on-(i<3)gO2:fOj=1.5toi/2:?"-";:nE
                                                2on-nOiaN1gO3:?">";
                                                3?:nE


                                                Not entirely sure about the byte count, this is based on the text representation for typing the valid program. It's a bit shorter on disk (91 bytes) because BASIC V2 uses a "tokenized" representation of programs.



                                                Online Demo



                                                Slightly "ungolfed":



                                                0 inputn:fori=1ton:oniand1goto1:print"<";    :rem read n from user, loop to n, if odd skip "<"
                                                1 on-(i<3)goto2:forj=1.5toi/2:print"-";:next :rem skip for i<3, print (i-1)/2 times "-"
                                                2 on-notiand1goto3:print">"; :rem if even skip ">"
                                                3 print:next :rem newline and next loop iteration






                                                share|improve this answer












                                                share|improve this answer



                                                share|improve this answer










                                                answered 10 hours ago









                                                Felix Palmen

                                                3,271525




                                                3,271525






















                                                    up vote
                                                    3
                                                    down vote














                                                    PowerShell, 62 56 50 bytes





                                                    param($n)(0..$n|%{($j='-'*$_)+'>';"<$j"})[0..--$n]


                                                    Try it online!



                                                    Loops from 0 up to input $n, each iteration creating two arrow strings. Those are then indexed with 0..--$n to pull out the correct number of elements.



                                                    Saved 6 bytes thanks to KGlasier.






                                                    share|improve this answer























                                                    • Messing around with my own solution I found a way to cut a few bytes on yours: Can save 4 bytes by wrapping the loop in brackets and indexing directly. ie param($n)(0..$n|%{($j='-'*$_++)+'>';"<$j"})[0..--$n]. So now you don't have to write $x twice.
                                                      – KGlasier
                                                      10 hours ago










                                                    • Also you can save two more bytes by not using ++ in ($j='-'*$_++) as you don't use $_ anywhere else.
                                                      – KGlasier
                                                      10 hours ago








                                                    • 1




                                                      @KGlasier Awesome - thanks for the obvious golfs! :)
                                                      – AdmBorkBork
                                                      9 hours ago















                                                    up vote
                                                    3
                                                    down vote














                                                    PowerShell, 62 56 50 bytes





                                                    param($n)(0..$n|%{($j='-'*$_)+'>';"<$j"})[0..--$n]


                                                    Try it online!



                                                    Loops from 0 up to input $n, each iteration creating two arrow strings. Those are then indexed with 0..--$n to pull out the correct number of elements.



                                                    Saved 6 bytes thanks to KGlasier.






                                                    share|improve this answer























                                                    • Messing around with my own solution I found a way to cut a few bytes on yours: Can save 4 bytes by wrapping the loop in brackets and indexing directly. ie param($n)(0..$n|%{($j='-'*$_++)+'>';"<$j"})[0..--$n]. So now you don't have to write $x twice.
                                                      – KGlasier
                                                      10 hours ago










                                                    • Also you can save two more bytes by not using ++ in ($j='-'*$_++) as you don't use $_ anywhere else.
                                                      – KGlasier
                                                      10 hours ago








                                                    • 1




                                                      @KGlasier Awesome - thanks for the obvious golfs! :)
                                                      – AdmBorkBork
                                                      9 hours ago













                                                    up vote
                                                    3
                                                    down vote










                                                    up vote
                                                    3
                                                    down vote










                                                    PowerShell, 62 56 50 bytes





                                                    param($n)(0..$n|%{($j='-'*$_)+'>';"<$j"})[0..--$n]


                                                    Try it online!



                                                    Loops from 0 up to input $n, each iteration creating two arrow strings. Those are then indexed with 0..--$n to pull out the correct number of elements.



                                                    Saved 6 bytes thanks to KGlasier.






                                                    share|improve this answer















                                                    PowerShell, 62 56 50 bytes





                                                    param($n)(0..$n|%{($j='-'*$_)+'>';"<$j"})[0..--$n]


                                                    Try it online!



                                                    Loops from 0 up to input $n, each iteration creating two arrow strings. Those are then indexed with 0..--$n to pull out the correct number of elements.



                                                    Saved 6 bytes thanks to KGlasier.







                                                    share|improve this answer














                                                    share|improve this answer



                                                    share|improve this answer








                                                    edited 9 hours ago

























                                                    answered 10 hours ago









                                                    AdmBorkBork

                                                    26k364226




                                                    26k364226












                                                    • Messing around with my own solution I found a way to cut a few bytes on yours: Can save 4 bytes by wrapping the loop in brackets and indexing directly. ie param($n)(0..$n|%{($j='-'*$_++)+'>';"<$j"})[0..--$n]. So now you don't have to write $x twice.
                                                      – KGlasier
                                                      10 hours ago










                                                    • Also you can save two more bytes by not using ++ in ($j='-'*$_++) as you don't use $_ anywhere else.
                                                      – KGlasier
                                                      10 hours ago








                                                    • 1




                                                      @KGlasier Awesome - thanks for the obvious golfs! :)
                                                      – AdmBorkBork
                                                      9 hours ago


















                                                    • Messing around with my own solution I found a way to cut a few bytes on yours: Can save 4 bytes by wrapping the loop in brackets and indexing directly. ie param($n)(0..$n|%{($j='-'*$_++)+'>';"<$j"})[0..--$n]. So now you don't have to write $x twice.
                                                      – KGlasier
                                                      10 hours ago










                                                    • Also you can save two more bytes by not using ++ in ($j='-'*$_++) as you don't use $_ anywhere else.
                                                      – KGlasier
                                                      10 hours ago








                                                    • 1




                                                      @KGlasier Awesome - thanks for the obvious golfs! :)
                                                      – AdmBorkBork
                                                      9 hours ago
















                                                    Messing around with my own solution I found a way to cut a few bytes on yours: Can save 4 bytes by wrapping the loop in brackets and indexing directly. ie param($n)(0..$n|%{($j='-'*$_++)+'>';"<$j"})[0..--$n]. So now you don't have to write $x twice.
                                                    – KGlasier
                                                    10 hours ago




                                                    Messing around with my own solution I found a way to cut a few bytes on yours: Can save 4 bytes by wrapping the loop in brackets and indexing directly. ie param($n)(0..$n|%{($j='-'*$_++)+'>';"<$j"})[0..--$n]. So now you don't have to write $x twice.
                                                    – KGlasier
                                                    10 hours ago












                                                    Also you can save two more bytes by not using ++ in ($j='-'*$_++) as you don't use $_ anywhere else.
                                                    – KGlasier
                                                    10 hours ago






                                                    Also you can save two more bytes by not using ++ in ($j='-'*$_++) as you don't use $_ anywhere else.
                                                    – KGlasier
                                                    10 hours ago






                                                    1




                                                    1




                                                    @KGlasier Awesome - thanks for the obvious golfs! :)
                                                    – AdmBorkBork
                                                    9 hours ago




                                                    @KGlasier Awesome - thanks for the obvious golfs! :)
                                                    – AdmBorkBork
                                                    9 hours ago










                                                    up vote
                                                    3
                                                    down vote














                                                    Jelly, 15 bytes



                                                    ị⁾><;’H”-ẋƲṚ⁸¡)


                                                    Try it online!






                                                    share|improve this answer

























                                                      up vote
                                                      3
                                                      down vote














                                                      Jelly, 15 bytes



                                                      ị⁾><;’H”-ẋƲṚ⁸¡)


                                                      Try it online!






                                                      share|improve this answer























                                                        up vote
                                                        3
                                                        down vote










                                                        up vote
                                                        3
                                                        down vote










                                                        Jelly, 15 bytes



                                                        ị⁾><;’H”-ẋƲṚ⁸¡)


                                                        Try it online!






                                                        share|improve this answer













                                                        Jelly, 15 bytes



                                                        ị⁾><;’H”-ẋƲṚ⁸¡)


                                                        Try it online!







                                                        share|improve this answer












                                                        share|improve this answer



                                                        share|improve this answer










                                                        answered 9 hours ago









                                                        Erik the Outgolfer

                                                        31k429102




                                                        31k429102






















                                                            up vote
                                                            2
                                                            down vote














                                                            Java (JDK), 81 bytes





                                                            n->{for(int i=0;i<n;)System.out.printf(i%2<1?"<%s%n":"%s>%n","-".repeat(i++/2));}


                                                            Try it online!



                                                            Explanations



                                                            n->{                  // int-accepting consumer
                                                            for(int i=0;i<n;) // for each i from 0 to n-1 included
                                                            System.out.printf( // output on stdout with a pattern
                                                            i%2<1 // if i is even:
                                                            ?"<%s%n" // use the left-arrow pattern
                                                            :"%s>%n", // else: use the right-arrow pattern
                                                            "-".repeat(i++/2) // fill the pattern with i/2 dashes, and increment i
                                                            ); //
                                                            } //





                                                            share|improve this answer



























                                                              up vote
                                                              2
                                                              down vote














                                                              Java (JDK), 81 bytes





                                                              n->{for(int i=0;i<n;)System.out.printf(i%2<1?"<%s%n":"%s>%n","-".repeat(i++/2));}


                                                              Try it online!



                                                              Explanations



                                                              n->{                  // int-accepting consumer
                                                              for(int i=0;i<n;) // for each i from 0 to n-1 included
                                                              System.out.printf( // output on stdout with a pattern
                                                              i%2<1 // if i is even:
                                                              ?"<%s%n" // use the left-arrow pattern
                                                              :"%s>%n", // else: use the right-arrow pattern
                                                              "-".repeat(i++/2) // fill the pattern with i/2 dashes, and increment i
                                                              ); //
                                                              } //





                                                              share|improve this answer

























                                                                up vote
                                                                2
                                                                down vote










                                                                up vote
                                                                2
                                                                down vote










                                                                Java (JDK), 81 bytes





                                                                n->{for(int i=0;i<n;)System.out.printf(i%2<1?"<%s%n":"%s>%n","-".repeat(i++/2));}


                                                                Try it online!



                                                                Explanations



                                                                n->{                  // int-accepting consumer
                                                                for(int i=0;i<n;) // for each i from 0 to n-1 included
                                                                System.out.printf( // output on stdout with a pattern
                                                                i%2<1 // if i is even:
                                                                ?"<%s%n" // use the left-arrow pattern
                                                                :"%s>%n", // else: use the right-arrow pattern
                                                                "-".repeat(i++/2) // fill the pattern with i/2 dashes, and increment i
                                                                ); //
                                                                } //





                                                                share|improve this answer















                                                                Java (JDK), 81 bytes





                                                                n->{for(int i=0;i<n;)System.out.printf(i%2<1?"<%s%n":"%s>%n","-".repeat(i++/2));}


                                                                Try it online!



                                                                Explanations



                                                                n->{                  // int-accepting consumer
                                                                for(int i=0;i<n;) // for each i from 0 to n-1 included
                                                                System.out.printf( // output on stdout with a pattern
                                                                i%2<1 // if i is even:
                                                                ?"<%s%n" // use the left-arrow pattern
                                                                :"%s>%n", // else: use the right-arrow pattern
                                                                "-".repeat(i++/2) // fill the pattern with i/2 dashes, and increment i
                                                                ); //
                                                                } //






                                                                share|improve this answer














                                                                share|improve this answer



                                                                share|improve this answer








                                                                edited 9 hours ago

























                                                                answered 10 hours ago









                                                                Olivier Grégoire

                                                                8,60711843




                                                                8,60711843






















                                                                    up vote
                                                                    2
                                                                    down vote














                                                                    SNOBOL4 (CSNOBOL4), 123 122 118 bytes



                                                                    	N =INPUT - 1
                                                                    P H =X / 2
                                                                    Y =DUPL('-',H)
                                                                    OUTPUT =EQ(H,X - H) Y '>' :S(I)
                                                                    OUTPUT ='<' Y
                                                                    I X =LT(X,N) X + 1 :S(P)
                                                                    END


                                                                    Try it online!






                                                                    share|improve this answer



























                                                                      up vote
                                                                      2
                                                                      down vote














                                                                      SNOBOL4 (CSNOBOL4), 123 122 118 bytes



                                                                      	N =INPUT - 1
                                                                      P H =X / 2
                                                                      Y =DUPL('-',H)
                                                                      OUTPUT =EQ(H,X - H) Y '>' :S(I)
                                                                      OUTPUT ='<' Y
                                                                      I X =LT(X,N) X + 1 :S(P)
                                                                      END


                                                                      Try it online!






                                                                      share|improve this answer

























                                                                        up vote
                                                                        2
                                                                        down vote










                                                                        up vote
                                                                        2
                                                                        down vote










                                                                        SNOBOL4 (CSNOBOL4), 123 122 118 bytes



                                                                        	N =INPUT - 1
                                                                        P H =X / 2
                                                                        Y =DUPL('-',H)
                                                                        OUTPUT =EQ(H,X - H) Y '>' :S(I)
                                                                        OUTPUT ='<' Y
                                                                        I X =LT(X,N) X + 1 :S(P)
                                                                        END


                                                                        Try it online!






                                                                        share|improve this answer















                                                                        SNOBOL4 (CSNOBOL4), 123 122 118 bytes



                                                                        	N =INPUT - 1
                                                                        P H =X / 2
                                                                        Y =DUPL('-',H)
                                                                        OUTPUT =EQ(H,X - H) Y '>' :S(I)
                                                                        OUTPUT ='<' Y
                                                                        I X =LT(X,N) X + 1 :S(P)
                                                                        END


                                                                        Try it online!







                                                                        share|improve this answer














                                                                        share|improve this answer



                                                                        share|improve this answer








                                                                        edited 9 hours ago

























                                                                        answered 10 hours ago









                                                                        Giuseppe

                                                                        16.4k31052




                                                                        16.4k31052






















                                                                            up vote
                                                                            2
                                                                            down vote














                                                                            V, 22 bytes



                                                                            i>
                                                                            <Àñäkjjé-já-ñÀGjdG


                                                                            Try it online!






                                                                            share|improve this answer

















                                                                            • 2




                                                                              This looks like some weird scandinavian language
                                                                              – Pavel
                                                                              9 hours ago















                                                                            up vote
                                                                            2
                                                                            down vote














                                                                            V, 22 bytes



                                                                            i>
                                                                            <Àñäkjjé-já-ñÀGjdG


                                                                            Try it online!






                                                                            share|improve this answer

















                                                                            • 2




                                                                              This looks like some weird scandinavian language
                                                                              – Pavel
                                                                              9 hours ago













                                                                            up vote
                                                                            2
                                                                            down vote










                                                                            up vote
                                                                            2
                                                                            down vote










                                                                            V, 22 bytes



                                                                            i>
                                                                            <Àñäkjjé-já-ñÀGjdG


                                                                            Try it online!






                                                                            share|improve this answer













                                                                            V, 22 bytes



                                                                            i>
                                                                            <Àñäkjjé-já-ñÀGjdG


                                                                            Try it online!







                                                                            share|improve this answer












                                                                            share|improve this answer



                                                                            share|improve this answer










                                                                            answered 9 hours ago









                                                                            DJMcMayhem

                                                                            40.7k11145308




                                                                            40.7k11145308








                                                                            • 2




                                                                              This looks like some weird scandinavian language
                                                                              – Pavel
                                                                              9 hours ago














                                                                            • 2




                                                                              This looks like some weird scandinavian language
                                                                              – Pavel
                                                                              9 hours ago








                                                                            2




                                                                            2




                                                                            This looks like some weird scandinavian language
                                                                            – Pavel
                                                                            9 hours ago




                                                                            This looks like some weird scandinavian language
                                                                            – Pavel
                                                                            9 hours ago










                                                                            up vote
                                                                            2
                                                                            down vote














                                                                            Charcoal, 16 bytes



                                                                            NθFθ«⊘ι↓>‖T»Fθ‖T


                                                                            Try it online! Link is to verbose version of code. I had three 17-byte solutions before I eventually stumbled over this one. Explanation:



                                                                            Nθ


                                                                            Input n.



                                                                            Fθ«


                                                                            Repeat n times, 0-indexed.



                                                                            ⊘ι


                                                                            Draw a line of -s of length half the index (truncated).



                                                                            ↓>


                                                                            Draw the arrowhead and move to the next line.



                                                                            ‖T»


                                                                            Reflect everything, flipping the arrowheads.



                                                                            Fθ‖T


                                                                            The above loop has n reflections, but we need an even number of reflections, so perform another n reflections.






                                                                            share|improve this answer

























                                                                              up vote
                                                                              2
                                                                              down vote














                                                                              Charcoal, 16 bytes



                                                                              NθFθ«⊘ι↓>‖T»Fθ‖T


                                                                              Try it online! Link is to verbose version of code. I had three 17-byte solutions before I eventually stumbled over this one. Explanation:



                                                                              Nθ


                                                                              Input n.



                                                                              Fθ«


                                                                              Repeat n times, 0-indexed.



                                                                              ⊘ι


                                                                              Draw a line of -s of length half the index (truncated).



                                                                              ↓>


                                                                              Draw the arrowhead and move to the next line.



                                                                              ‖T»


                                                                              Reflect everything, flipping the arrowheads.



                                                                              Fθ‖T


                                                                              The above loop has n reflections, but we need an even number of reflections, so perform another n reflections.






                                                                              share|improve this answer























                                                                                up vote
                                                                                2
                                                                                down vote










                                                                                up vote
                                                                                2
                                                                                down vote










                                                                                Charcoal, 16 bytes



                                                                                NθFθ«⊘ι↓>‖T»Fθ‖T


                                                                                Try it online! Link is to verbose version of code. I had three 17-byte solutions before I eventually stumbled over this one. Explanation:



                                                                                Nθ


                                                                                Input n.



                                                                                Fθ«


                                                                                Repeat n times, 0-indexed.



                                                                                ⊘ι


                                                                                Draw a line of -s of length half the index (truncated).



                                                                                ↓>


                                                                                Draw the arrowhead and move to the next line.



                                                                                ‖T»


                                                                                Reflect everything, flipping the arrowheads.



                                                                                Fθ‖T


                                                                                The above loop has n reflections, but we need an even number of reflections, so perform another n reflections.






                                                                                share|improve this answer













                                                                                Charcoal, 16 bytes



                                                                                NθFθ«⊘ι↓>‖T»Fθ‖T


                                                                                Try it online! Link is to verbose version of code. I had three 17-byte solutions before I eventually stumbled over this one. Explanation:



                                                                                Nθ


                                                                                Input n.



                                                                                Fθ«


                                                                                Repeat n times, 0-indexed.



                                                                                ⊘ι


                                                                                Draw a line of -s of length half the index (truncated).



                                                                                ↓>


                                                                                Draw the arrowhead and move to the next line.



                                                                                ‖T»


                                                                                Reflect everything, flipping the arrowheads.



                                                                                Fθ‖T


                                                                                The above loop has n reflections, but we need an even number of reflections, so perform another n reflections.







                                                                                share|improve this answer












                                                                                share|improve this answer



                                                                                share|improve this answer










                                                                                answered 6 hours ago









                                                                                Neil

                                                                                78.8k744175




                                                                                78.8k744175






















                                                                                    up vote
                                                                                    2
                                                                                    down vote














                                                                                    Japt -m, 16 bytes



                                                                                    "<>"¬hUu Uz ç-)q


                                                                                    Try it online!



                                                                                    Updated with a completely new method.



                                                                                    Explanation:



                                                                                                        #Implicitly map over the range [0..input) as U
                                                                                    "<>" #The string "<>"
                                                                                    ¬ #Split into the array ["<",">"]
                                                                                    hUu ) #Replace the element at index U modulo 2 with:
                                                                                    - # The character '-'
                                                                                    ç # Repeated a number of times equal to
                                                                                    Uz # U integer divided by 2
                                                                                    q #Join the array to a string





                                                                                    share|improve this answer



















                                                                                    • 1




                                                                                      ç auto-casts its first parameter into a string, so you can drop the '.
                                                                                      – Oliver
                                                                                      2 hours ago















                                                                                    up vote
                                                                                    2
                                                                                    down vote














                                                                                    Japt -m, 16 bytes



                                                                                    "<>"¬hUu Uz ç-)q


                                                                                    Try it online!



                                                                                    Updated with a completely new method.



                                                                                    Explanation:



                                                                                                        #Implicitly map over the range [0..input) as U
                                                                                    "<>" #The string "<>"
                                                                                    ¬ #Split into the array ["<",">"]
                                                                                    hUu ) #Replace the element at index U modulo 2 with:
                                                                                    - # The character '-'
                                                                                    ç # Repeated a number of times equal to
                                                                                    Uz # U integer divided by 2
                                                                                    q #Join the array to a string





                                                                                    share|improve this answer



















                                                                                    • 1




                                                                                      ç auto-casts its first parameter into a string, so you can drop the '.
                                                                                      – Oliver
                                                                                      2 hours ago













                                                                                    up vote
                                                                                    2
                                                                                    down vote










                                                                                    up vote
                                                                                    2
                                                                                    down vote










                                                                                    Japt -m, 16 bytes



                                                                                    "<>"¬hUu Uz ç-)q


                                                                                    Try it online!



                                                                                    Updated with a completely new method.



                                                                                    Explanation:



                                                                                                        #Implicitly map over the range [0..input) as U
                                                                                    "<>" #The string "<>"
                                                                                    ¬ #Split into the array ["<",">"]
                                                                                    hUu ) #Replace the element at index U modulo 2 with:
                                                                                    - # The character '-'
                                                                                    ç # Repeated a number of times equal to
                                                                                    Uz # U integer divided by 2
                                                                                    q #Join the array to a string





                                                                                    share|improve this answer















                                                                                    Japt -m, 16 bytes



                                                                                    "<>"¬hUu Uz ç-)q


                                                                                    Try it online!



                                                                                    Updated with a completely new method.



                                                                                    Explanation:



                                                                                                        #Implicitly map over the range [0..input) as U
                                                                                    "<>" #The string "<>"
                                                                                    ¬ #Split into the array ["<",">"]
                                                                                    hUu ) #Replace the element at index U modulo 2 with:
                                                                                    - # The character '-'
                                                                                    ç # Repeated a number of times equal to
                                                                                    Uz # U integer divided by 2
                                                                                    q #Join the array to a string






                                                                                    share|improve this answer














                                                                                    share|improve this answer



                                                                                    share|improve this answer








                                                                                    edited 31 mins ago

























                                                                                    answered 9 hours ago









                                                                                    Kamil Drakari

                                                                                    2,861416




                                                                                    2,861416








                                                                                    • 1




                                                                                      ç auto-casts its first parameter into a string, so you can drop the '.
                                                                                      – Oliver
                                                                                      2 hours ago














                                                                                    • 1




                                                                                      ç auto-casts its first parameter into a string, so you can drop the '.
                                                                                      – Oliver
                                                                                      2 hours ago








                                                                                    1




                                                                                    1




                                                                                    ç auto-casts its first parameter into a string, so you can drop the '.
                                                                                    – Oliver
                                                                                    2 hours ago




                                                                                    ç auto-casts its first parameter into a string, so you can drop the '.
                                                                                    – Oliver
                                                                                    2 hours ago










                                                                                    up vote
                                                                                    1
                                                                                    down vote













                                                                                    JavaScript (ES6), 58 bytes



                                                                                    Returns a space-separated string.





                                                                                    n=>(g=p=>n--?k++&1?`<${p} `+g(p+'-'):p+'> '+g(p):'')(k='')


                                                                                    Try it online!






                                                                                    share|improve this answer

























                                                                                      up vote
                                                                                      1
                                                                                      down vote













                                                                                      JavaScript (ES6), 58 bytes



                                                                                      Returns a space-separated string.





                                                                                      n=>(g=p=>n--?k++&1?`<${p} `+g(p+'-'):p+'> '+g(p):'')(k='')


                                                                                      Try it online!






                                                                                      share|improve this answer























                                                                                        up vote
                                                                                        1
                                                                                        down vote










                                                                                        up vote
                                                                                        1
                                                                                        down vote









                                                                                        JavaScript (ES6), 58 bytes



                                                                                        Returns a space-separated string.





                                                                                        n=>(g=p=>n--?k++&1?`<${p} `+g(p+'-'):p+'> '+g(p):'')(k='')


                                                                                        Try it online!






                                                                                        share|improve this answer












                                                                                        JavaScript (ES6), 58 bytes



                                                                                        Returns a space-separated string.





                                                                                        n=>(g=p=>n--?k++&1?`<${p} `+g(p+'-'):p+'> '+g(p):'')(k='')


                                                                                        Try it online!







                                                                                        share|improve this answer












                                                                                        share|improve this answer



                                                                                        share|improve this answer










                                                                                        answered 10 hours ago









                                                                                        Arnauld

                                                                                        71.3k688298




                                                                                        71.3k688298






















                                                                                            up vote
                                                                                            1
                                                                                            down vote














                                                                                            Haskell, 51 bytes





                                                                                            (`take`do b<-['-'<$[1..n]|n<-[0..]];[b++">",'<':b])


                                                                                            Try it online!



                                                                                            Explanation / Ungolfed



                                                                                            Using do-notation saves us a concat, using '-'<$[1..n] is shorter than replicate, and finally using infix-notation allows a pointfree function with take, undoing these would give:



                                                                                            f n = take n $ concat [ [b++">", '<':b] | n<-[0..], let b = replicate n '-' ]





                                                                                            share|improve this answer



























                                                                                              up vote
                                                                                              1
                                                                                              down vote














                                                                                              Haskell, 51 bytes





                                                                                              (`take`do b<-['-'<$[1..n]|n<-[0..]];[b++">",'<':b])


                                                                                              Try it online!



                                                                                              Explanation / Ungolfed



                                                                                              Using do-notation saves us a concat, using '-'<$[1..n] is shorter than replicate, and finally using infix-notation allows a pointfree function with take, undoing these would give:



                                                                                              f n = take n $ concat [ [b++">", '<':b] | n<-[0..], let b = replicate n '-' ]





                                                                                              share|improve this answer

























                                                                                                up vote
                                                                                                1
                                                                                                down vote










                                                                                                up vote
                                                                                                1
                                                                                                down vote










                                                                                                Haskell, 51 bytes





                                                                                                (`take`do b<-['-'<$[1..n]|n<-[0..]];[b++">",'<':b])


                                                                                                Try it online!



                                                                                                Explanation / Ungolfed



                                                                                                Using do-notation saves us a concat, using '-'<$[1..n] is shorter than replicate, and finally using infix-notation allows a pointfree function with take, undoing these would give:



                                                                                                f n = take n $ concat [ [b++">", '<':b] | n<-[0..], let b = replicate n '-' ]





                                                                                                share|improve this answer















                                                                                                Haskell, 51 bytes





                                                                                                (`take`do b<-['-'<$[1..n]|n<-[0..]];[b++">",'<':b])


                                                                                                Try it online!



                                                                                                Explanation / Ungolfed



                                                                                                Using do-notation saves us a concat, using '-'<$[1..n] is shorter than replicate, and finally using infix-notation allows a pointfree function with take, undoing these would give:



                                                                                                f n = take n $ concat [ [b++">", '<':b] | n<-[0..], let b = replicate n '-' ]






                                                                                                share|improve this answer














                                                                                                share|improve this answer



                                                                                                share|improve this answer








                                                                                                edited 9 hours ago

























                                                                                                answered 9 hours ago









                                                                                                BMO

                                                                                                11k21881




                                                                                                11k21881






















                                                                                                    up vote
                                                                                                    1
                                                                                                    down vote













                                                                                                    Haskell, 41 bytes



                                                                                                    (`take`g"")
                                                                                                    g p=(p++">"):('<':p):g('-':p)


                                                                                                    Try it online!



                                                                                                    Plain old recursion: start with an emtpy string p, collect p with a right arrow, a left arrow with p and a recursive call with p one - longer. Take the first n items of this list.






                                                                                                    share|improve this answer



























                                                                                                      up vote
                                                                                                      1
                                                                                                      down vote













                                                                                                      Haskell, 41 bytes



                                                                                                      (`take`g"")
                                                                                                      g p=(p++">"):('<':p):g('-':p)


                                                                                                      Try it online!



                                                                                                      Plain old recursion: start with an emtpy string p, collect p with a right arrow, a left arrow with p and a recursive call with p one - longer. Take the first n items of this list.






                                                                                                      share|improve this answer

























                                                                                                        up vote
                                                                                                        1
                                                                                                        down vote










                                                                                                        up vote
                                                                                                        1
                                                                                                        down vote









                                                                                                        Haskell, 41 bytes



                                                                                                        (`take`g"")
                                                                                                        g p=(p++">"):('<':p):g('-':p)


                                                                                                        Try it online!



                                                                                                        Plain old recursion: start with an emtpy string p, collect p with a right arrow, a left arrow with p and a recursive call with p one - longer. Take the first n items of this list.






                                                                                                        share|improve this answer














                                                                                                        Haskell, 41 bytes



                                                                                                        (`take`g"")
                                                                                                        g p=(p++">"):('<':p):g('-':p)


                                                                                                        Try it online!



                                                                                                        Plain old recursion: start with an emtpy string p, collect p with a right arrow, a left arrow with p and a recursive call with p one - longer. Take the first n items of this list.







                                                                                                        share|improve this answer














                                                                                                        share|improve this answer



                                                                                                        share|improve this answer








                                                                                                        edited 9 hours ago

























                                                                                                        answered 9 hours ago









                                                                                                        nimi

                                                                                                        31.1k31985




                                                                                                        31.1k31985






















                                                                                                            up vote
                                                                                                            1
                                                                                                            down vote













                                                                                                            Powershell, 51 bytes





                                                                                                            param($n)0..$n|%{'-'*$_+'>';'<'+'-'*$_}|?{$n---gt0}





                                                                                                            share|improve this answer

























                                                                                                              up vote
                                                                                                              1
                                                                                                              down vote













                                                                                                              Powershell, 51 bytes





                                                                                                              param($n)0..$n|%{'-'*$_+'>';'<'+'-'*$_}|?{$n---gt0}





                                                                                                              share|improve this answer























                                                                                                                up vote
                                                                                                                1
                                                                                                                down vote










                                                                                                                up vote
                                                                                                                1
                                                                                                                down vote









                                                                                                                Powershell, 51 bytes





                                                                                                                param($n)0..$n|%{'-'*$_+'>';'<'+'-'*$_}|?{$n---gt0}





                                                                                                                share|improve this answer












                                                                                                                Powershell, 51 bytes





                                                                                                                param($n)0..$n|%{'-'*$_+'>';'<'+'-'*$_}|?{$n---gt0}






                                                                                                                share|improve this answer












                                                                                                                share|improve this answer



                                                                                                                share|improve this answer










                                                                                                                answered 9 hours ago









                                                                                                                mazzy

                                                                                                                1,985314




                                                                                                                1,985314






















                                                                                                                    up vote
                                                                                                                    1
                                                                                                                    down vote














                                                                                                                    05AB1E, 23 bytes



                                                                                                                    FN2%D"><"è'-N2÷∍«s_iR},


                                                                                                                    Try it online!



                                                                                                                    First time using 05AB1E or any other golfing language for that matter. Any ideas welcome.






                                                                                                                    share|improve this answer

























                                                                                                                      up vote
                                                                                                                      1
                                                                                                                      down vote














                                                                                                                      05AB1E, 23 bytes



                                                                                                                      FN2%D"><"è'-N2÷∍«s_iR},


                                                                                                                      Try it online!



                                                                                                                      First time using 05AB1E or any other golfing language for that matter. Any ideas welcome.






                                                                                                                      share|improve this answer























                                                                                                                        up vote
                                                                                                                        1
                                                                                                                        down vote










                                                                                                                        up vote
                                                                                                                        1
                                                                                                                        down vote










                                                                                                                        05AB1E, 23 bytes



                                                                                                                        FN2%D"><"è'-N2÷∍«s_iR},


                                                                                                                        Try it online!



                                                                                                                        First time using 05AB1E or any other golfing language for that matter. Any ideas welcome.






                                                                                                                        share|improve this answer













                                                                                                                        05AB1E, 23 bytes



                                                                                                                        FN2%D"><"è'-N2÷∍«s_iR},


                                                                                                                        Try it online!



                                                                                                                        First time using 05AB1E or any other golfing language for that matter. Any ideas welcome.







                                                                                                                        share|improve this answer












                                                                                                                        share|improve this answer



                                                                                                                        share|improve this answer










                                                                                                                        answered 7 hours ago









                                                                                                                        nedla2004

                                                                                                                        3211310




                                                                                                                        3211310






















                                                                                                                            up vote
                                                                                                                            1
                                                                                                                            down vote













                                                                                                                            Java 123 bytes



                                                                                                                            n->{String l="",r="";for(int c=0;c<n;c++)System.out.println(c%2==0?r=c==0?">":c==1?"<":"-"+r:(l+=c==0?">":c==1?"<":"-"));}





                                                                                                                            share|improve this answer

























                                                                                                                              up vote
                                                                                                                              1
                                                                                                                              down vote













                                                                                                                              Java 123 bytes



                                                                                                                              n->{String l="",r="";for(int c=0;c<n;c++)System.out.println(c%2==0?r=c==0?">":c==1?"<":"-"+r:(l+=c==0?">":c==1?"<":"-"));}





                                                                                                                              share|improve this answer























                                                                                                                                up vote
                                                                                                                                1
                                                                                                                                down vote










                                                                                                                                up vote
                                                                                                                                1
                                                                                                                                down vote









                                                                                                                                Java 123 bytes



                                                                                                                                n->{String l="",r="";for(int c=0;c<n;c++)System.out.println(c%2==0?r=c==0?">":c==1?"<":"-"+r:(l+=c==0?">":c==1?"<":"-"));}





                                                                                                                                share|improve this answer












                                                                                                                                Java 123 bytes



                                                                                                                                n->{String l="",r="";for(int c=0;c<n;c++)System.out.println(c%2==0?r=c==0?">":c==1?"<":"-"+r:(l+=c==0?">":c==1?"<":"-"));}






                                                                                                                                share|improve this answer












                                                                                                                                share|improve this answer



                                                                                                                                share|improve this answer










                                                                                                                                answered 5 hours ago









                                                                                                                                isaace

                                                                                                                                1714




                                                                                                                                1714






















                                                                                                                                    up vote
                                                                                                                                    1
                                                                                                                                    down vote














                                                                                                                                    Clean, 76 73 bytes



                                                                                                                                    import StdEnv,StdLib
                                                                                                                                    $n=take n[s\i<-inits['--'..],s<-[i++['>'],['<':i]]]


                                                                                                                                    Try it online!



                                                                                                                                    Uses the neat fact that ['-','-'..] is the same as ['--'..] to save a bit.






                                                                                                                                    share|improve this answer

























                                                                                                                                      up vote
                                                                                                                                      1
                                                                                                                                      down vote














                                                                                                                                      Clean, 76 73 bytes



                                                                                                                                      import StdEnv,StdLib
                                                                                                                                      $n=take n[s\i<-inits['--'..],s<-[i++['>'],['<':i]]]


                                                                                                                                      Try it online!



                                                                                                                                      Uses the neat fact that ['-','-'..] is the same as ['--'..] to save a bit.






                                                                                                                                      share|improve this answer























                                                                                                                                        up vote
                                                                                                                                        1
                                                                                                                                        down vote










                                                                                                                                        up vote
                                                                                                                                        1
                                                                                                                                        down vote










                                                                                                                                        Clean, 76 73 bytes



                                                                                                                                        import StdEnv,StdLib
                                                                                                                                        $n=take n[s\i<-inits['--'..],s<-[i++['>'],['<':i]]]


                                                                                                                                        Try it online!



                                                                                                                                        Uses the neat fact that ['-','-'..] is the same as ['--'..] to save a bit.






                                                                                                                                        share|improve this answer













                                                                                                                                        Clean, 76 73 bytes



                                                                                                                                        import StdEnv,StdLib
                                                                                                                                        $n=take n[s\i<-inits['--'..],s<-[i++['>'],['<':i]]]


                                                                                                                                        Try it online!



                                                                                                                                        Uses the neat fact that ['-','-'..] is the same as ['--'..] to save a bit.







                                                                                                                                        share|improve this answer












                                                                                                                                        share|improve this answer



                                                                                                                                        share|improve this answer










                                                                                                                                        answered 5 hours ago









                                                                                                                                        Οurous

                                                                                                                                        6,18311032




                                                                                                                                        6,18311032






















                                                                                                                                            up vote
                                                                                                                                            1
                                                                                                                                            down vote














                                                                                                                                            6502 machine code (C64), 49 bytes



                                                                                                                                            00 C0 20 9B B7 A2 00 8A 4A A8 90 05 A9 3C 20 D2 FF A9 2D C0 00 F0 06 20 D2 FF 
                                                                                                                                            88 D0 FA 8A 4A B0 05 A9 3E 20 D2 FF A9 0D 20 D2 FF E8 E4 65 D0 D7 60


                                                                                                                                            Still quite a bit shorter than BASIC ;) This one has a number range only up to 255 because the natural integer size of the machine has only 8 bits.



                                                                                                                                            Online demo



                                                                                                                                            Usage: SYS49152,[n] (e.g. SYS49152,3 for the example from the challenge)



                                                                                                                                            Commented disassembly:



                                                                                                                                                     00 C0       .WORD $C000        ; load address
                                                                                                                                            .C:c000 20 9B B7 JSR $B79B ; get unsigned byte from commandline
                                                                                                                                            .C:c003 A2 00 LDX #$00 ; main loop counter
                                                                                                                                            .C:c005 .loop:
                                                                                                                                            .C:c005 8A TXA ; loop counter to accumulator
                                                                                                                                            .C:c006 4A LSR A ; divide by 2, shift lowest bit to C
                                                                                                                                            .C:c007 A8 TAY ; result to Y
                                                                                                                                            .C:c008 90 05 BCC .toright ; C clear -> counter even, skip '<'
                                                                                                                                            .C:c00a A9 3C LDA #$3C ; load character '<'
                                                                                                                                            .C:c00c 20 D2 FF JSR $FFD2 ; output character
                                                                                                                                            .C:c00f .toright:
                                                                                                                                            .C:c00f A9 2D LDA #$2D ; load character '-'
                                                                                                                                            .C:c011 C0 00 CPY #$00 ; counter/2 == 0 ? then no dashes
                                                                                                                                            .C:c013 F0 06 BEQ .skipdashes
                                                                                                                                            .C:c015 .printdashes:
                                                                                                                                            .C:c015 20 D2 FF JSR $FFD2 ; output character
                                                                                                                                            .C:c018 88 DEY ; decrement Y
                                                                                                                                            .C:c019 D0 FA BNE .printdashes ; not 0 yet -> repeat
                                                                                                                                            .C:c01b .skipdashes:
                                                                                                                                            .C:c01b 8A TXA ; loop counter to accumulator
                                                                                                                                            .C:c01c 4A LSR A ; shift lowest bit to C
                                                                                                                                            .C:c01d B0 05 BCS .toleft ; C set -> counter odd, skip '>'
                                                                                                                                            .C:c01f A9 3E LDA #$3E ; load character '>'
                                                                                                                                            .C:c021 20 D2 FF JSR $FFD2 ; output character
                                                                                                                                            .C:c024 .toleft:
                                                                                                                                            .C:c024 A9 0D LDA #$0D ; load newline character
                                                                                                                                            .C:c026 20 D2 FF JSR $FFD2 ; output character
                                                                                                                                            .C:c029 E8 INX ; next loop iteration
                                                                                                                                            .C:c02a E4 65 CPX $65 ; compare to command line argument
                                                                                                                                            .C:c02c D0 D7 BNE .loop ; not reached yet -> repeat main loop
                                                                                                                                            .C:c02e 60 RTS ; exit





                                                                                                                                            share|improve this answer

























                                                                                                                                              up vote
                                                                                                                                              1
                                                                                                                                              down vote














                                                                                                                                              6502 machine code (C64), 49 bytes



                                                                                                                                              00 C0 20 9B B7 A2 00 8A 4A A8 90 05 A9 3C 20 D2 FF A9 2D C0 00 F0 06 20 D2 FF 
                                                                                                                                              88 D0 FA 8A 4A B0 05 A9 3E 20 D2 FF A9 0D 20 D2 FF E8 E4 65 D0 D7 60


                                                                                                                                              Still quite a bit shorter than BASIC ;) This one has a number range only up to 255 because the natural integer size of the machine has only 8 bits.



                                                                                                                                              Online demo



                                                                                                                                              Usage: SYS49152,[n] (e.g. SYS49152,3 for the example from the challenge)



                                                                                                                                              Commented disassembly:



                                                                                                                                                       00 C0       .WORD $C000        ; load address
                                                                                                                                              .C:c000 20 9B B7 JSR $B79B ; get unsigned byte from commandline
                                                                                                                                              .C:c003 A2 00 LDX #$00 ; main loop counter
                                                                                                                                              .C:c005 .loop:
                                                                                                                                              .C:c005 8A TXA ; loop counter to accumulator
                                                                                                                                              .C:c006 4A LSR A ; divide by 2, shift lowest bit to C
                                                                                                                                              .C:c007 A8 TAY ; result to Y
                                                                                                                                              .C:c008 90 05 BCC .toright ; C clear -> counter even, skip '<'
                                                                                                                                              .C:c00a A9 3C LDA #$3C ; load character '<'
                                                                                                                                              .C:c00c 20 D2 FF JSR $FFD2 ; output character
                                                                                                                                              .C:c00f .toright:
                                                                                                                                              .C:c00f A9 2D LDA #$2D ; load character '-'
                                                                                                                                              .C:c011 C0 00 CPY #$00 ; counter/2 == 0 ? then no dashes
                                                                                                                                              .C:c013 F0 06 BEQ .skipdashes
                                                                                                                                              .C:c015 .printdashes:
                                                                                                                                              .C:c015 20 D2 FF JSR $FFD2 ; output character
                                                                                                                                              .C:c018 88 DEY ; decrement Y
                                                                                                                                              .C:c019 D0 FA BNE .printdashes ; not 0 yet -> repeat
                                                                                                                                              .C:c01b .skipdashes:
                                                                                                                                              .C:c01b 8A TXA ; loop counter to accumulator
                                                                                                                                              .C:c01c 4A LSR A ; shift lowest bit to C
                                                                                                                                              .C:c01d B0 05 BCS .toleft ; C set -> counter odd, skip '>'
                                                                                                                                              .C:c01f A9 3E LDA #$3E ; load character '>'
                                                                                                                                              .C:c021 20 D2 FF JSR $FFD2 ; output character
                                                                                                                                              .C:c024 .toleft:
                                                                                                                                              .C:c024 A9 0D LDA #$0D ; load newline character
                                                                                                                                              .C:c026 20 D2 FF JSR $FFD2 ; output character
                                                                                                                                              .C:c029 E8 INX ; next loop iteration
                                                                                                                                              .C:c02a E4 65 CPX $65 ; compare to command line argument
                                                                                                                                              .C:c02c D0 D7 BNE .loop ; not reached yet -> repeat main loop
                                                                                                                                              .C:c02e 60 RTS ; exit





                                                                                                                                              share|improve this answer























                                                                                                                                                up vote
                                                                                                                                                1
                                                                                                                                                down vote










                                                                                                                                                up vote
                                                                                                                                                1
                                                                                                                                                down vote










                                                                                                                                                6502 machine code (C64), 49 bytes



                                                                                                                                                00 C0 20 9B B7 A2 00 8A 4A A8 90 05 A9 3C 20 D2 FF A9 2D C0 00 F0 06 20 D2 FF 
                                                                                                                                                88 D0 FA 8A 4A B0 05 A9 3E 20 D2 FF A9 0D 20 D2 FF E8 E4 65 D0 D7 60


                                                                                                                                                Still quite a bit shorter than BASIC ;) This one has a number range only up to 255 because the natural integer size of the machine has only 8 bits.



                                                                                                                                                Online demo



                                                                                                                                                Usage: SYS49152,[n] (e.g. SYS49152,3 for the example from the challenge)



                                                                                                                                                Commented disassembly:



                                                                                                                                                         00 C0       .WORD $C000        ; load address
                                                                                                                                                .C:c000 20 9B B7 JSR $B79B ; get unsigned byte from commandline
                                                                                                                                                .C:c003 A2 00 LDX #$00 ; main loop counter
                                                                                                                                                .C:c005 .loop:
                                                                                                                                                .C:c005 8A TXA ; loop counter to accumulator
                                                                                                                                                .C:c006 4A LSR A ; divide by 2, shift lowest bit to C
                                                                                                                                                .C:c007 A8 TAY ; result to Y
                                                                                                                                                .C:c008 90 05 BCC .toright ; C clear -> counter even, skip '<'
                                                                                                                                                .C:c00a A9 3C LDA #$3C ; load character '<'
                                                                                                                                                .C:c00c 20 D2 FF JSR $FFD2 ; output character
                                                                                                                                                .C:c00f .toright:
                                                                                                                                                .C:c00f A9 2D LDA #$2D ; load character '-'
                                                                                                                                                .C:c011 C0 00 CPY #$00 ; counter/2 == 0 ? then no dashes
                                                                                                                                                .C:c013 F0 06 BEQ .skipdashes
                                                                                                                                                .C:c015 .printdashes:
                                                                                                                                                .C:c015 20 D2 FF JSR $FFD2 ; output character
                                                                                                                                                .C:c018 88 DEY ; decrement Y
                                                                                                                                                .C:c019 D0 FA BNE .printdashes ; not 0 yet -> repeat
                                                                                                                                                .C:c01b .skipdashes:
                                                                                                                                                .C:c01b 8A TXA ; loop counter to accumulator
                                                                                                                                                .C:c01c 4A LSR A ; shift lowest bit to C
                                                                                                                                                .C:c01d B0 05 BCS .toleft ; C set -> counter odd, skip '>'
                                                                                                                                                .C:c01f A9 3E LDA #$3E ; load character '>'
                                                                                                                                                .C:c021 20 D2 FF JSR $FFD2 ; output character
                                                                                                                                                .C:c024 .toleft:
                                                                                                                                                .C:c024 A9 0D LDA #$0D ; load newline character
                                                                                                                                                .C:c026 20 D2 FF JSR $FFD2 ; output character
                                                                                                                                                .C:c029 E8 INX ; next loop iteration
                                                                                                                                                .C:c02a E4 65 CPX $65 ; compare to command line argument
                                                                                                                                                .C:c02c D0 D7 BNE .loop ; not reached yet -> repeat main loop
                                                                                                                                                .C:c02e 60 RTS ; exit





                                                                                                                                                share|improve this answer













                                                                                                                                                6502 machine code (C64), 49 bytes



                                                                                                                                                00 C0 20 9B B7 A2 00 8A 4A A8 90 05 A9 3C 20 D2 FF A9 2D C0 00 F0 06 20 D2 FF 
                                                                                                                                                88 D0 FA 8A 4A B0 05 A9 3E 20 D2 FF A9 0D 20 D2 FF E8 E4 65 D0 D7 60


                                                                                                                                                Still quite a bit shorter than BASIC ;) This one has a number range only up to 255 because the natural integer size of the machine has only 8 bits.



                                                                                                                                                Online demo



                                                                                                                                                Usage: SYS49152,[n] (e.g. SYS49152,3 for the example from the challenge)



                                                                                                                                                Commented disassembly:



                                                                                                                                                         00 C0       .WORD $C000        ; load address
                                                                                                                                                .C:c000 20 9B B7 JSR $B79B ; get unsigned byte from commandline
                                                                                                                                                .C:c003 A2 00 LDX #$00 ; main loop counter
                                                                                                                                                .C:c005 .loop:
                                                                                                                                                .C:c005 8A TXA ; loop counter to accumulator
                                                                                                                                                .C:c006 4A LSR A ; divide by 2, shift lowest bit to C
                                                                                                                                                .C:c007 A8 TAY ; result to Y
                                                                                                                                                .C:c008 90 05 BCC .toright ; C clear -> counter even, skip '<'
                                                                                                                                                .C:c00a A9 3C LDA #$3C ; load character '<'
                                                                                                                                                .C:c00c 20 D2 FF JSR $FFD2 ; output character
                                                                                                                                                .C:c00f .toright:
                                                                                                                                                .C:c00f A9 2D LDA #$2D ; load character '-'
                                                                                                                                                .C:c011 C0 00 CPY #$00 ; counter/2 == 0 ? then no dashes
                                                                                                                                                .C:c013 F0 06 BEQ .skipdashes
                                                                                                                                                .C:c015 .printdashes:
                                                                                                                                                .C:c015 20 D2 FF JSR $FFD2 ; output character
                                                                                                                                                .C:c018 88 DEY ; decrement Y
                                                                                                                                                .C:c019 D0 FA BNE .printdashes ; not 0 yet -> repeat
                                                                                                                                                .C:c01b .skipdashes:
                                                                                                                                                .C:c01b 8A TXA ; loop counter to accumulator
                                                                                                                                                .C:c01c 4A LSR A ; shift lowest bit to C
                                                                                                                                                .C:c01d B0 05 BCS .toleft ; C set -> counter odd, skip '>'
                                                                                                                                                .C:c01f A9 3E LDA #$3E ; load character '>'
                                                                                                                                                .C:c021 20 D2 FF JSR $FFD2 ; output character
                                                                                                                                                .C:c024 .toleft:
                                                                                                                                                .C:c024 A9 0D LDA #$0D ; load newline character
                                                                                                                                                .C:c026 20 D2 FF JSR $FFD2 ; output character
                                                                                                                                                .C:c029 E8 INX ; next loop iteration
                                                                                                                                                .C:c02a E4 65 CPX $65 ; compare to command line argument
                                                                                                                                                .C:c02c D0 D7 BNE .loop ; not reached yet -> repeat main loop
                                                                                                                                                .C:c02e 60 RTS ; exit






                                                                                                                                                share|improve this answer












                                                                                                                                                share|improve this answer



                                                                                                                                                share|improve this answer










                                                                                                                                                answered 5 hours ago









                                                                                                                                                Felix Palmen

                                                                                                                                                3,271525




                                                                                                                                                3,271525






















                                                                                                                                                    up vote
                                                                                                                                                    1
                                                                                                                                                    down vote














                                                                                                                                                    Perl 5, 44 bytes





                                                                                                                                                    map{$_/=2;say'<'x/./,'-'x$_,'>'x!$&}0..<>-1


                                                                                                                                                    Try it online!






                                                                                                                                                    share|improve this answer

























                                                                                                                                                      up vote
                                                                                                                                                      1
                                                                                                                                                      down vote














                                                                                                                                                      Perl 5, 44 bytes





                                                                                                                                                      map{$_/=2;say'<'x/./,'-'x$_,'>'x!$&}0..<>-1


                                                                                                                                                      Try it online!






                                                                                                                                                      share|improve this answer























                                                                                                                                                        up vote
                                                                                                                                                        1
                                                                                                                                                        down vote










                                                                                                                                                        up vote
                                                                                                                                                        1
                                                                                                                                                        down vote










                                                                                                                                                        Perl 5, 44 bytes





                                                                                                                                                        map{$_/=2;say'<'x/./,'-'x$_,'>'x!$&}0..<>-1


                                                                                                                                                        Try it online!






                                                                                                                                                        share|improve this answer













                                                                                                                                                        Perl 5, 44 bytes





                                                                                                                                                        map{$_/=2;say'<'x/./,'-'x$_,'>'x!$&}0..<>-1


                                                                                                                                                        Try it online!







                                                                                                                                                        share|improve this answer












                                                                                                                                                        share|improve this answer



                                                                                                                                                        share|improve this answer










                                                                                                                                                        answered 4 hours ago









                                                                                                                                                        Xcali

                                                                                                                                                        5,059520




                                                                                                                                                        5,059520






















                                                                                                                                                            up vote
                                                                                                                                                            1
                                                                                                                                                            down vote













                                                                                                                                                            Japt -m, 16 15 13 bytes



                                                                                                                                                            g"><" iUUz ç-


                                                                                                                                                            Test it online






                                                                                                                                                            share|improve this answer



























                                                                                                                                                              up vote
                                                                                                                                                              1
                                                                                                                                                              down vote













                                                                                                                                                              Japt -m, 16 15 13 bytes



                                                                                                                                                              g"><" iUUz ç-


                                                                                                                                                              Test it online






                                                                                                                                                              share|improve this answer

























                                                                                                                                                                up vote
                                                                                                                                                                1
                                                                                                                                                                down vote










                                                                                                                                                                up vote
                                                                                                                                                                1
                                                                                                                                                                down vote









                                                                                                                                                                Japt -m, 16 15 13 bytes



                                                                                                                                                                g"><" iUUz ç-


                                                                                                                                                                Test it online






                                                                                                                                                                share|improve this answer














                                                                                                                                                                Japt -m, 16 15 13 bytes



                                                                                                                                                                g"><" iUUz ç-


                                                                                                                                                                Test it online







                                                                                                                                                                share|improve this answer














                                                                                                                                                                share|improve this answer



                                                                                                                                                                share|improve this answer








                                                                                                                                                                edited 2 hours ago

























                                                                                                                                                                answered 7 hours ago









                                                                                                                                                                Oliver

                                                                                                                                                                4,6901831




                                                                                                                                                                4,6901831






















                                                                                                                                                                    up vote
                                                                                                                                                                    0
                                                                                                                                                                    down vote














                                                                                                                                                                    Perl 6, 39 bytes





                                                                                                                                                                    {map {'<'x$_%2~'-'x$_/2~'>'x$_%%2},^$_}


                                                                                                                                                                    Try it online!



                                                                                                                                                                    Anonymous code block that returns a list of lines.






                                                                                                                                                                    share|improve this answer

























                                                                                                                                                                      up vote
                                                                                                                                                                      0
                                                                                                                                                                      down vote














                                                                                                                                                                      Perl 6, 39 bytes





                                                                                                                                                                      {map {'<'x$_%2~'-'x$_/2~'>'x$_%%2},^$_}


                                                                                                                                                                      Try it online!



                                                                                                                                                                      Anonymous code block that returns a list of lines.






                                                                                                                                                                      share|improve this answer























                                                                                                                                                                        up vote
                                                                                                                                                                        0
                                                                                                                                                                        down vote










                                                                                                                                                                        up vote
                                                                                                                                                                        0
                                                                                                                                                                        down vote










                                                                                                                                                                        Perl 6, 39 bytes





                                                                                                                                                                        {map {'<'x$_%2~'-'x$_/2~'>'x$_%%2},^$_}


                                                                                                                                                                        Try it online!



                                                                                                                                                                        Anonymous code block that returns a list of lines.






                                                                                                                                                                        share|improve this answer













                                                                                                                                                                        Perl 6, 39 bytes





                                                                                                                                                                        {map {'<'x$_%2~'-'x$_/2~'>'x$_%%2},^$_}


                                                                                                                                                                        Try it online!



                                                                                                                                                                        Anonymous code block that returns a list of lines.







                                                                                                                                                                        share|improve this answer












                                                                                                                                                                        share|improve this answer



                                                                                                                                                                        share|improve this answer










                                                                                                                                                                        answered 3 hours ago









                                                                                                                                                                        Jo King

                                                                                                                                                                        20.3k245107




                                                                                                                                                                        20.3k245107






























                                                                                                                                                                            draft saved

                                                                                                                                                                            draft discarded




















































                                                                                                                                                                            If this is an answer to a challenge…




                                                                                                                                                                            • …Be sure to follow the challenge specification. However, please refrain from exploiting obvious loopholes. Answers abusing any of the standard loopholes are considered invalid. If you think a specification is unclear or underspecified, comment on the question instead.


                                                                                                                                                                            • …Try to optimize your score. For instance, answers to code-golf challenges should attempt to be as short as possible. You can always include a readable version of the code in addition to the competitive one.
                                                                                                                                                                              Explanations of your answer make it more interesting to read and are very much encouraged.


                                                                                                                                                                            • …Include a short header which indicates the language(s) of your code and its score, as defined by the challenge.



                                                                                                                                                                            More generally…




                                                                                                                                                                            • …Please make sure to answer the question and provide sufficient detail.


                                                                                                                                                                            • …Avoid asking for help, clarification or responding to other answers (use comments instead).






                                                                                                                                                                            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                                                                                                                                                                            Please pay close attention to the following guidance:


                                                                                                                                                                            • Please be sure to answer the question. Provide details and share your research!

                                                                                                                                                                            But avoid



                                                                                                                                                                            • Asking for help, clarification, or responding to other answers.

                                                                                                                                                                            • Making statements based on opinion; back them up with references or personal experience.


                                                                                                                                                                            To learn more, see our tips on writing great answers.




                                                                                                                                                                            draft saved


                                                                                                                                                                            draft discarded














                                                                                                                                                                            StackExchange.ready(
                                                                                                                                                                            function () {
                                                                                                                                                                            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f177454%2fdraw-some-expanding-arrows%23new-answer', 'question_page');
                                                                                                                                                                            }
                                                                                                                                                                            );

                                                                                                                                                                            Post as a guest















                                                                                                                                                                            Required, but never shown





















































                                                                                                                                                                            Required, but never shown














                                                                                                                                                                            Required, but never shown












                                                                                                                                                                            Required, but never shown







                                                                                                                                                                            Required, but never shown

































                                                                                                                                                                            Required, but never shown














                                                                                                                                                                            Required, but never shown












                                                                                                                                                                            Required, but never shown







                                                                                                                                                                            Required, but never shown







                                                                                                                                                                            Popular posts from this blog

                                                                                                                                                                            Morgemoulin

                                                                                                                                                                            Scott Moir

                                                                                                                                                                            Souastre