18
\$\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\$
12
  • 14
    \$\begingroup\$ I think it's pretty silly to call this common symbol a "meme arrow". They're obviously comedy chevrons. \$\endgroup\$ Jun 10, 2019 at 18:04
  • 8
    \$\begingroup\$ @Christian They're actually amusing angles \$\endgroup\$
    – anna328p
    Jun 10, 2019 at 20:39
  • 5
    \$\begingroup\$ @ArtemisFowl I thought they were interesting increases \$\endgroup\$
    – anna328p
    Jun 12, 2019 at 22:17
  • 3
    \$\begingroup\$ @dkudravtsev Not silly signage? \$\endgroup\$
    – Miriam
    Jun 12, 2019 at 22:19
  • 4
    \$\begingroup\$ > Is me > Challenge about meme arrows exists > Writes comment using meme arrows because it's ironic > No one reads comment > Frick \$\endgroup\$
    – lyxal
    Oct 7, 2020 at 3:09

55 Answers 55

1
2
1
\$\begingroup\$

Python 3, 91 86 bytes

n=range(int(input()))
for i in n:print(' '*i+'\\')
for i in n:print(' '*(n[-1]-i)+'/')

Try it online!

Edit 1: saved 5 bytes by making n a range instead of integer

\$\endgroup\$
5
  • \$\begingroup\$ You can golf this a bit if you port this to Python 2 :) And there are definitely more optimizations you can make! \$\endgroup\$
    – RGS
    Mar 25, 2020 at 19:00
  • \$\begingroup\$ @RGS, Thanks! Don't really want to switch to python 2, but here is your port in 77 bytes Try it online! \$\endgroup\$
    – Dion
    Mar 26, 2020 at 7:27
  • \$\begingroup\$ 80 bytes \$\endgroup\$
    – Jo King
    Aug 16, 2020 at 6:44
  • \$\begingroup\$ Or even 73 bytes using exec \$\endgroup\$
    – Jo King
    Aug 16, 2020 at 6:51
  • \$\begingroup\$ 71 even if trailing spaces after \ are acceptable... \$\endgroup\$ Sep 11, 2020 at 14:42
1
\$\begingroup\$

MATL, 14 13 12 bytes

Xy92*t45-Pvc

1 Byte saved thanks to @LuisMendo

Explanation

        % Implicitly grab the input as an integer
Xy      % Create an identity matrix this size
92*     % Multiply by 92 (ASCII for '\')
t       % Duplicate the matrix
45-     % Subtract 45 from every element yielding 47 (ASCII for '/') on the diagonal
        % and -45 everywhere else
P       % Vertically flip this matrix
v       % Vertically concatenate the two matrices
c       % Convert to characters (negative numbers are replaced with a space)
        % Implicitly display the result

Try it out at MATL Online

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

Vyxal j, 95 bitsv2, 11.875 bytes

ƛI\\JøṀ;½fyRṘJ

Try it Online!

Bitstring:

00001000000011101111110001100110011110111010010010110001001000111000011010000100001110000011111

Beats all non-canvas users

\$\endgroup\$
3
  • \$\begingroup\$ Well it’s 14 SBCS which loses to MATL, and I can’t tell if the 10-byte Stax is using a canvas \$\endgroup\$
    – noodle man
    Feb 13 at 13:40
  • \$\begingroup\$ stax has byte packing \$\endgroup\$
    – pacman256
    Feb 13 at 14:34
  • \$\begingroup\$ So? That's not so different from vyncode \$\endgroup\$
    – noodle man
    Feb 13 at 15:27
1
\$\begingroup\$

YASEPL, 58 bytes

=i=a'(`1=b;space,i~>"\"!+}7,a`2!-=b;space,i~>divide!}7,0,2

and just for fun...

ibe, 118 bytes

adadadadadadaddsRafWmreafYmpeafUmtiakqskTagTmwakwafTmwslWssTmQmwaaYafQmwssQmRmqakeskTakrafTmwslWssTmQmraaUagQmwsaQmqme

(this is an esolang i made a while ago that i dont plan on releasing)

\$\endgroup\$
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\$
0
\$\begingroup\$

J, 19 bytes

' \/'{~(,2*|.)@=@i.

Try it online!

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

JavaScript (Node.js), 59 bytes

n=>eval("for(o='';s=''.padEnd(n--);)o=s+`\\\\\n${o+s}/\n`")

Attempt This Online!

I had a different idea, it didn't turn out as golfy as the obvious method but I still felt like posting it.

The program constructs the string with a for loop, counting down from n, and continuously sets a string o to: n spaces, backtick, newline, o, n spaces, forward slash, newline.

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

Go, 133 bytes

import."strings"
func f(n int)(o string){for i:=0;i<n;i++{o+=Repeat(` `,i)+"\\\n"}
for i:=n;i>0;i--{o+=Repeat(` `,i-1)+"/\n"}
return}

Attempt This Online!

Go 1.22+, 131 bytes

import."strings"
func f(n int)(o string){for i:=range n{o+=Repeat(` `,i)+"\\\n"}
for i:=range n{o+=Repeat(` `,n-i-1)+"/\n"}
return}

You cannot Attempt This Online!

Run it on the Go Playground!

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

Perl 5 + -p, 20 bytes

Uses non-printable characters (backspace 0x08 and form feed 0x0c) to position the characters in the terminal.

$_='\.'x$_."./.."x$_

Try it online!

Explanation

Stores in $_ a repetition of the literal string \<FF> $_ (implicit input) times, concatenated with <BS>/<FF><BS> repeated $_ times.

$_ is then output implicitly by -p.

\$\endgroup\$
1
2

Your Answer

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

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