16
\$\begingroup\$

Specifications

Given a number n, output an ASCII "meme arrow" (greater-than symbol, >) of size n.

n will always be a positive integer, greater than 0.

Examples

n = 2

\
 \
 /
/

n = 5

\
 \
  \
   \
    \
    /
   /
  /
 /
/

Sample code

Here is a sample program, written in Crystal, that returns the correct results. Run it as ./arrow 10.

arrow.cr:

def f(i)
        i.times { |j|
                j.times { print ' ' }
                puts "\\"
        }
        i.times { |j|
                (i-j-1).times { print ' ' }
                puts '/'
        }
end

f(ARGV[0].to_i)

Rules

  • This is . The shortest answer wins. However, I will not select an answer, because the shortest answer may change over time.
  • Standard loopholes are not allowed.
\$\endgroup\$
10
  • 1
    \$\begingroup\$ Are you sure this is not a duplicate (that is, did you sandbox this)? I think this is likely to be, but it's slightly nearly impossible to search for. \$\endgroup\$ Jun 9, 2019 at 4:46
  • 11
    \$\begingroup\$ I think it's pretty silly to call this common symbol a "meme arrow". They're obviously comedy chevrons. \$\endgroup\$
    – scatter
    Jun 10, 2019 at 18:04
  • 6
    \$\begingroup\$ @Christian They're actually amusing angles \$\endgroup\$
    – anna328p
    Jun 10, 2019 at 20:39
  • 4
    \$\begingroup\$ @ArtemisFowl I thought they were interesting increases \$\endgroup\$
    – anna328p
    Jun 12, 2019 at 22:17
  • 2
    \$\begingroup\$ @dkudravtsev Not silly signage? \$\endgroup\$
    – Artemis
    Jun 12, 2019 at 22:19

47 Answers 47

1
2
0
\$\begingroup\$

Python 2, 63 bytes

f=lambda n,s='':n and f(n-1,~-n*' '+'\\\n'+s+~-n*' '+'/\n')or s

Try it online!

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

Stax, 10 bytes

Ç₧¥╗M'gQ9⌂

Run and debug it

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

SimpleTemplate, 100 bytes

This was quite a fun challenge, but some bugs in the language made it hard to optimize.

{@set_ argv.0}{@while_}{@callstr_repeat intoS" ",_}{@setO S,"\\\n",O,S,"/\n"}{@incby-1_}{@/}{@echoO}

Basically, cycles throught the values backwards, working the string from the middle out.


How the answer should be

Due to the bugs, the code wasn't being interpreted properly.

This is how the code would be, if the compiler didn't had any bug (86 bytes):

{@forfrom argv.0to0step-1}{@callrepeat intoS" ",_}{@setO S,"\\
",O,S,"/
"}{@/}{@echoO}

Oh, well, at least the solution works :x

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

JavaScript (Node.js), 42 bytes (If trailing new line is allowed)

n=>(F=s=>n--?s+`\\
`+F(s+" ")+s+`/
`:"")``

Try it online!

JavaScript (Node.js), 48 46 bytes

n=>(F=s=>s+`\\
${--n?F(s+" ")+`
`:""}${s}/`)``

Try it online!

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

Java 8, 80 bytes

n->{for(int i=0;i<2*n;)System.out.printf("%"+(i++<n?i:n-~n-i)+"c\n",i>n?47:92);}

Try it online.

Explanation:

n->{                    // Method with integer parameter and no return-type
  for(int i=0;i<2*n;)   //  Loop `i` in the range [0, 2 * input `n`):
    System.out.printf(  //   Print with format:
      "%"+(i++<n?       //    If `i` is smaller than input `n`:
                        //    (and increase `i` by 1 right after this check with `i++`)
            i           //     Use `i` leading spaces
           :            //    Else:
            n-~n-i)     //     Use `2 * n - i + 1` leading spaces
      +"c\n",i>n?       //    If `i` is larger than input `n`:
              47        //     Append a trailing '/' and newline
             :          //    Else:
              92);}     //     Append a trailing '\' and newline
\$\endgroup\$
0
\$\begingroup\$

Japt -R, 15 bytes

"\\/"¬c@õ!ùX zY

Try it

õ!ù'\ cUÆ'/ ùU´

Try it

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

Pyth, 23 bytes

V2VQ
+*?N--QH1H\ ?N\/\\

Try it online!

Note that the program must not have a terminating newline! If saving it on linux, you can remove the last byte in a file using head -c -1 <file>.

I think this is the first time I have used for loops in pyth? Anyways, this is a rather direct port of the example source code in the question (though the 2 loops are combined, and the innermost loop is converted into string multiplication, and the remaining 2 prints are joined into one).

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

Batch File, 117 + 9 bytes

Executed using cmd/v/q/c.

for /l %%i in (1,1,%1)do (for /l %%j in (2,1,%%i)do set %%i= !%%i!)&echo !%%i!\
for /l %%i in (%1,-1,1)do echo !%%i!/
\$\endgroup\$
0
\$\begingroup\$

Pyth, 18 bytes

js.e+R?k\/\\b_B*L;

Try it online!

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

Python 3.8 (pre-release), 80 bytes

lambda n:'\n'.join([' '*i+'\\'for i in(r:=range(n))]+[' '*(n+~i)+'/'for i in r])

Try it online!

Same approach as the one I suggested to @Artemis Fowl, but takes advantage of the walrus operator.

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

Swift 5/Xcode 10.2.1, 91 bytes

(0..<n*2).map{String(repeating:" ",count:$0<n ?$0:n*2-$0-1)+($0<n ?"\\":"/")+"\n"}.joined()   

Try it online!

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

Pepe, 91 bytes

rErEeEeEEEeeREeEREErereeereeERrEeeEeeeeeRrEeeeReereRerEEEererEeeEeEEEErEEEEREErereeereeERee

Try it online!

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

Perl 5, 59 bytes

$_--;say$"x$_."\\"for(0..$_);say$"x$_."/"for(reverse 0..$_)

Example execution:

perl -nE '$_--;say$"x$_."\\"for(0..$_);say$"x$_."/"for(reverse 0..$_)'

Waits for an integer to be provided on STDIN when executed. Once provided, it will display the arrow.

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

Rockstar, 85 bytes

listen to N
X's0
while N-X
say " "*X+"\"
let X be+1

while X
let X be-1
say " "*X+"/"

Try it here (Code will need to be pasted in)

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

Husk, 23 bytes

+mo`:'\R' ŀ¹mo`:'/R' ↔ŀ

Try it online!

There is probably a way to halve the size of this program.

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

Forth (gforth), 72 bytes

: f dup 0 ?do i spaces 92 emit cr loop 1- for i spaces 47 emit cr next ;

Try it online!

there's probably a better way to do this.

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

Zsh, 46 bytes

/ \\()for a;<<<${(l:a:)0};\\ {1..$1};/ {$1..1}

Try it online!

It really ought to be possible to get shorter than this...

\$\endgroup\$
1
2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.