19
\$\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.
asked Jun 9, 2019 at 4:31
\$\endgroup\$
12
  • 15
    \$\begingroup\$ I think it's pretty silly to call this common symbol a "meme arrow". They're obviously comedy chevrons. \$\endgroup\$ Commented Jun 10, 2019 at 18:04
  • 9
    \$\begingroup\$ @Christian They're actually amusing angles \$\endgroup\$ Commented Jun 10, 2019 at 20:39
  • 6
    \$\begingroup\$ @ArtemisFowl I thought they were interesting increases \$\endgroup\$ Commented Jun 12, 2019 at 22:17
  • 3
    \$\begingroup\$ @dkudravtsev Not silly signage? \$\endgroup\$ Commented 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\$ Commented Oct 7, 2020 at 3:09

57 Answers 57

1
2
13
\$\begingroup\$
answered Jun 9, 2019 at 7:33
\$\endgroup\$
1
  • 1
    \$\begingroup\$ Code itself is like smile actually. \$\endgroup\$ Commented Jun 9, 2019 at 20:14
10
\$\begingroup\$

C (gcc), 56 bytes

f(n,i){for(i=-n;n;printf("%*c\n",i?++i+n:n--,i?92:47));}

Try it online!

f(n,i){for(i=-n;i;printf("%*c\n", ++i+n , 92 )); //first print descending '\'s
 for( ;n;printf("%*c\n", n--, 47));} // then print returning '/'s
answered Jun 9, 2019 at 10:25
\$\endgroup\$
7
\$\begingroup\$

Python 2, 54 bytes

f=lambda n,p='':n*'?'and p+'\\\n'+f(n-1,p+' ')+p+'/\n'

Try it online!

Outputs with a trailing newline.

answered Jun 9, 2019 at 6:21
\$\endgroup\$
5
\$\begingroup\$

C# (Visual C# Interactive Compiler), 66 bytes

n=>new int[n*2].Select((a,b)=>"".PadLeft(b<n?b:n*2+~b)+"\\/"[b/n])

Saved a byte thanks to @someone.

Try it online!

answered Jun 9, 2019 at 4:50
\$\endgroup\$
1
  • 1
    \$\begingroup\$ n*2-b-1 -> n*2+~b \$\endgroup\$ Commented Jun 9, 2019 at 4:57
5
\$\begingroup\$

Perl 5 -p, 36 bytes

$\=($q=$"x$_)."\\
$\$q/
"while$_--}{

Try it online!

answered Jun 9, 2019 at 6:01
\$\endgroup\$
5
\$\begingroup\$

05AB1E, 6 bytes

'3円.Λ∊

Try it online!

Explanation

 .Λ # draw
'\ # the string "\"
 # of length input
 3 # in the south-eastern direction
 ∊ # then vertically mirror it
answered Jun 9, 2019 at 9:55
\$\endgroup\$
4
\$\begingroup\$

PowerShell, (削除) 44 (削除ここまで) 41 bytes

filter f{if($_){'\'
--$_|f|%{" $_"}
'/'}}

Try it online!

answered Jun 10, 2019 at 5:18
\$\endgroup\$
4
\$\begingroup\$

C64Mini/C64 BASIC (and other CBM BASIC variants), 52 tokenized BASIC bytes used

 0INPUTN:N=N-1:FORI=0TON:PRINTTAB(I)"\":NEXT:FORI=NTO0STEP-1:PRINTTAB(I)"/":NEXT

Here is the non-obfuscated version for exaplantion:

 0 INPUT N
 1 LET N=N-1
 2 FOR I=0 TO N
 3 PRINT TAB(I);"\"
 4 NEXT I
 5 FOR I=N TO 0 STEP -1
 6 PRINT TAB(I);"/"
 7 NEXT I

What ever number is entered into N in line zero is reduced by one as the TAB command is zero-indexed; The FOR/NEXT loops in lines two through to four and five through to seven then output the upper and lower part if the meme arrow respectively (represented by a shifted M and shifted N in graphics mode source)

Commodore C64 meme arrow

answered Jun 10, 2019 at 11:22
\$\endgroup\$
8
  • 1
    \$\begingroup\$ Did you know that in Commodore Basic all keywords can be abbreviated? Here's a link: c64-wiki.com/wiki/BASIC_keyword_abbreviation For example, for can be fO (f - shoft o), print is ?, etc. \$\endgroup\$ Commented Jun 15, 2019 at 17:09
  • 1
    \$\begingroup\$ 52 bytes is misleading in Code Golf, the binaries don't count, just the source code. It shoulf be something ike this: 0inputn:n=n-1:fOi=0ton:?tA(i)"\":nE:fOi=0ton:?tA(i)"/":nE - it takes 57 bytes. \$\endgroup\$ Commented Jun 15, 2019 at 17:10
  • 1
    \$\begingroup\$ As discussed here -> codegolf.meta.stackexchange.com/questions/11553/… I count the tokens used as this is more representative of how much of the memory is being used. \$\endgroup\$ Commented Jun 17, 2019 at 8:39
  • 1
    \$\begingroup\$ Oh, I didn't know this. Is there a decision about this? Even the answer has not been accepted there. \$\endgroup\$ Commented Jun 17, 2019 at 8:45
  • 1
    \$\begingroup\$ My first computer was a C16, I did a lot of assembly on that, too, so no offence, I love Commodore. C16 had Basic 3,5, 80 chars per line, I also had a book with the ROM listings explained, so I exactly knew how the tokenization and listing worked, \$\endgroup\$ Commented Jun 17, 2019 at 9:41
4
\$\begingroup\$

MarioLANG, (削除) 719 (削除ここまで) 677 bytes

+
+
+
+
+
+ ((((+)+++++)))<
+>======================"
+)++++++)+++++++++++((-[!)
========================#=-
) ![- <+;)+++)---)++++)<
)=#======"=================
) >)+)+((!
+ "======#
 <))))).(((((((<
 ========">============"
>)+)+((-[!+)) -[!((((((((.)).))))+(-[!)
"========#=============#====================#<
!) <
#==========================================="
 >(((((.)))>
 "========<"========
 ![-)).))).(((((((![- ))+![-((+)+)<((![<
 #================#=========#========"==#="===
 > ! >-!
 "===================================# "=#

Try it online!

This was harder than expected...

answered Jun 10, 2019 at 10:30
\$\endgroup\$
4
\$\begingroup\$

brainfuck, 125 bytes

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

Try it online!

++++++++++[->+>+++++++++>+++<<<]>>++>++> ; Initialize with " \"
, ; Get input
[-> ; loop and decrement n 
 [->+<<<.>>] ; output number of spaces, copy n
 <<<. ; output \
 <. ; output newline
 >>>> 
 >[-<+>]<+ ; copy copy of n back to original place 
<]
<<[--<<+>>]<<+>> ; change "\" to "/"
>>> 
[ ; second loop for bottom half
 - ; decrement n
 [-<+<.>>] ; output n spaces
 <<<<<.>. ; output \ and newline
 >>>[->+<]> ; copy n back
]
answered Jun 13, 2019 at 19:48
\$\endgroup\$
4
\$\begingroup\$

Ruby, (削除) 111 (削除ここまで) (削除) 99 (削除ここまで) (削除) 77 (削除ここまで) (削除) 73 (削除ここまで) (削除) 68 (削除ここまで) (削除) 64 (削除ここまで) (削除) 57 (削除ここまで) 56 bytes

-12 bytes thanks to Benjamin Urquhart, -43 thanks to manatwork and -2 bytes thanks to Value Ink.

->i{s=[];puts (0...i).map{|j|s=(p=' '*j)+?/,*s;p+?\\},s}

Try it online!

Explanation:

f=->i{ # instead of a function, use a lambda
 s=[] # needs a helper variable *now*, for scope
 puts( # puts takes arbitrary num of args; \n after each
 (0...i).map{|j| # not from 0 to i but from 0 to i-1 (*three* dots)
 s=(
 p=' '*j # p will remain in scope inside of .map,
 )
 +?/ # character literal instead of string
 ,*s # essentially appending to the array
 
 p+?\\ # p is what's returned by .map, not s!
 
 }, # up until here, 1st arg to display
 s # NOW, as the *2nd* arg, s is displayed
 )
}

Alternative (but longer) Solutions

A friend read this answer and then tried to come up with a couple more approaches. Putting them here, too, so that they're not lost to the vast interwebs.

inject and unshift, 72 bytes

->n{puts (0...n).inject([]){|s,i|i=' '*(n-1-i);s.unshift i+?\\;s<<i+?/}}

Try it online!

downto, inject and unshift, 80 bytes

->n{puts n.downto(1).map{|i|' '*(i-1)}.inject([]){|s,i|s<<i+?/;s.unshift i+?\\}}

Try it online!

intriguing, two non-nested loops, 127 bytes

->n{
r=->s,c{s[0..-(c+1)],s[-c..-1]=s[c..-1],s[0..c-1];s};
n.times{|i|puts r[' '*n+?\,円n-i]}
n.times{|i|puts r[' '*n+?/,i+1]}
}

Try it online!

answered Jun 9, 2019 at 22:54
\$\endgroup\$
13
  • \$\begingroup\$ Can't a lot of that whitespace be removed? \$\endgroup\$ Commented Jun 9, 2019 at 23:17
  • 1
    \$\begingroup\$ Yes, 12 bytes in total, thank you! This was the first time I submitted anything to a code golf game... \$\endgroup\$ Commented Jun 10, 2019 at 9:08
  • \$\begingroup\$ Then you may find interesting the Tips for golfing in Ruby, or even the Tips for golfing in <all languages>. \$\endgroup\$ Commented Jun 10, 2019 at 9:11
  • \$\begingroup\$ You could replace the inner loops for padding with String#rjust (Try it online!). \$\endgroup\$ Commented Jun 10, 2019 at 9:21
  • \$\begingroup\$ Here I applied some of the tips from the above mentioned 2 collections to reduce it to 57 characters: Try it online! \$\endgroup\$ Commented Jun 10, 2019 at 9:58
3
\$\begingroup\$

Charcoal, 5 bytes

↘N‖M↓

Try it online! Link is to verbose version of code. Explanation:

↘N

Input a number and print a diagonal line of \s of that length.

‖M↓

Reflect the line vertically.

answered Jun 9, 2019 at 8:58
\$\endgroup\$
3
\$\begingroup\$

T-SQL code, 80 bytes

DECLARE @ INT=3
,@z INT=0
x:PRINT
space(@-abs(@[email protected]))+char(92-@z/@*45)SET
@z+=1IF @z<@*2GOTO x

Try it online

T-SQL query, 96 bytes

In order to make this work online i had to make some minor alterations. Spaces in the beginning of a row doesn't display in the online snippet. So I am using ascii 160 instead. When running in management studio, it is possible to change the settings to show result as text, which would result in the correct spaces in this posted script.

DECLARE @ INT=3
SELECT space(@-abs(@-number-.5))+char(92-number/@*45)FROM
spt_values WHERE number<@*2and'p'=type

Try it online

answered Jun 9, 2019 at 12:38
\$\endgroup\$
3
\$\begingroup\$

MAWP, 69 bytes

%@!0//[!1A]%[1A[1A84W;]%99W25WM1M;25W;]%[!1A]~[1A[1A84W;]%67W5M;25W;]

I am not going to golf this further bcause funny number. Sorry, guys.

Try it!

answered Aug 16, 2020 at 6:30
\$\endgroup\$
1
  • 1
    \$\begingroup\$ +1 for 69!! (15chrs) \$\endgroup\$ Commented Aug 17, 2020 at 2:20
2
\$\begingroup\$

APL(NARS), 40 chars, 80 bytes

{f←{⍺,⍨⍵⍴' '}⋄⊃('\'f ̈k),('/'f ̈⌽k← ̄1+⍳⍵)}

test:

 h←{f←{⍺,⍨⍵⍴' '}⋄⊃('\'f ̈k),('/'f ̈⌽k← ̄1+⍳⍵)}
 h 2
\ 
 \
 /
/ 
 h 5
\ 
 \ 
 \ 
 \ 
 \
 /
 / 
 / 
 / 
/ 
answered Jun 9, 2019 at 9:26
\$\endgroup\$
2
\$\begingroup\$

TypeScript's type system, 87 bytes

//@ts-nocheck
type F<N,S="">=N extends[{},...infer N]?`
${S}\\${F<N,`${S} `>}
${S}/`:""

Try it at the TypeScript playground

Takes input as a unary number represented by a tuple type N. If I instead took the unary number as a string type of spaces, this becomes 71 bytes:

type F<S,O=''>=S extends` ${infer S}`?F<S,`${S}\\
${O&string}${S}/
`>:O

Try it at the TS playground

I like the shorter version better because it's tail-recursive and just overall really elegant, but I think the I/O format is a little cheaty.

answered Feb 13, 2024 at 20:31
\$\endgroup\$
2
\$\begingroup\$

Vyxal, 8 bytes

ɾ\\↳↲øṀ§

Try it Online!

 ↳ # Right-pad
 \\ # \
ɾ # To length each of range(1, n+1)
 ↲ # Left-pad each to length n
 øṀ # Mirror, flipping slashes
 § # Vertical join, transposing and joining by newlines
answered Feb 13, 2024 at 23:45
\$\endgroup\$
1
\$\begingroup\$

Retina 0.8.2, 32 bytes

.+
$* ¶$&$* 
\G.
¶$`\
r`.\G
$'/¶

Try it online! Explanation:

.+
$* ¶$&$* 

Generate two lines of n spaces.

\G.
¶$`\

Turn the top line into a \ diagonal.

r`.\G
$'/¶

Turn the bottom line into a / diagonal.

answered Jun 9, 2019 at 10:08
\$\endgroup\$
1
\$\begingroup\$

C (gcc), (削除) 67 (削除ここまで) 65 bytes

-2 bytes thanks to ceilingcat

f(n,i){for(i=~n;i++<n;)i&&printf("%*c\n",n-abs(i)+1,"/\\"[i<0]);}

Try it online!

answered Jun 9, 2019 at 6:13
\$\endgroup\$
0
1
\$\begingroup\$

Python 2, (削除) 85 (削除ここまで) (削除) 84 (削除ここまで) (削除) 81 (削除ここまで) (削除) 80 (削除ここまで) 75 bytes

def a(n):l="for i in range(n):print' '*";exec l+"i+'\\\\'\n"+l+"(n+~i)+'/'"

Try it online!

answered Jun 9, 2019 at 19:27
\$\endgroup\$
4
  • 1
    \$\begingroup\$ -1 with r-strings: def a(n):l="for i in range(n):print' '*";exec l+r"i+'\\'\n"+l+"(n+~i)+'/'" \$\endgroup\$ Commented Apr 22, 2021 at 20:43
  • \$\begingroup\$ @Makonede Leads to a SyntaxError unfortunately :( \$\endgroup\$ Commented Apr 23, 2021 at 7:19
  • \$\begingroup\$ Ah, maybe r-strings weren't a thing in Python 2. Oh well. \$\endgroup\$ Commented Apr 23, 2021 at 15:33
  • \$\begingroup\$ They were, but the \n can't be in a raw string even in Python 3. \$\endgroup\$ Commented Apr 23, 2021 at 16:02
1
\$\begingroup\$

PowerShell, 50 bytes

param($n)0..--$n|%{' '*$_+'\'}
$n..0|%{' '*$_+'/'}

Try it online!

Will look into making it so it only goes through the range once. Not bad for the no brain method though.

answered Jun 10, 2019 at 2:19
\$\endgroup\$
0
1
\$\begingroup\$

Twig, 115 bytes

Builds the string backwards, "returning" it in the end.

Uses a macro to generate all the results.

{%macro a(N,s="")%}{%for i in N..1%}{%set s=('%'~i~'s
'~s~'%'~i~'s
')|format('\\','/')%}{%endfor%}{{s}}{%endmacro%}

This macro has to be in a file, and imported like this:

{% import 'macro.twig' as a %}
{{ a.a(<value>) }}

You can try it on https://twigfiddle.com/5hzlpz (click on "Show raw result").

answered Jun 10, 2019 at 6:46
\$\endgroup\$
1
\$\begingroup\$

Haskell, (削除) 52 (削除ここまで) 49 bytes

-3 bytes thanks to Sriotchilism O'Zaic.

unlines.g
g 0=[]
g n="\\":map(' ':)(g$n-1)++["/"]

Try it online!

answered Jun 9, 2019 at 18:18
\$\endgroup\$
1
  • 1
    \$\begingroup\$ You can save a byte with g$n-1 instead of g(n-1). You also don't need to count the f= since f never gets referenced. \$\endgroup\$ Commented Jun 10, 2019 at 15:53
1
\$\begingroup\$

Pyth, 19 bytes

VQ+*dN\\)V_Q+*dhN\/

Try it online!

TIL multiplying a string by a negative value multiplies it by its absolute value.

answered Jun 12, 2019 at 2:13
\$\endgroup\$
1
\$\begingroup\$

Python 3, (削除) 90 (削除ここまで) 83 bytes

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

Try it online!

-7 bytes thanks to @squid

answered Jun 12, 2019 at 14:59
\$\endgroup\$
4
  • \$\begingroup\$ 83 bytes, but I feel like it can still go down \$\endgroup\$ Commented Jun 13, 2019 at 12:55
  • 1
    \$\begingroup\$ I wish this was possible. \$\endgroup\$ Commented Jun 13, 2019 at 14:45
  • \$\begingroup\$ Soon... \$\endgroup\$ Commented Jun 13, 2019 at 14:50
  • \$\begingroup\$ Oh yeah I forgot about that. Maybe you should submit it! \$\endgroup\$ Commented Jun 13, 2019 at 14:54
1
\$\begingroup\$

Rockstar, 133 bytes

Try it online here!

F takes N,S
If N is 0
Give back N
Say S+"\"
Let T be S+" "
Let M be N-1
F taking M,T
Say S+"/"
Listen to X
F taking X,""

Since Rockstar is not famous for string operations, it takes relatively lots of code to do it (recursively was even longer).

The size of the arrow is taken as input.

answered Jun 15, 2019 at 17:05
\$\endgroup\$
1
\$\begingroup\$

PHP, (削除) 79 (削除ここまで) (削除) 63 (削除ここまで) 61 bytes

function f($x,$s=''){if($x)echo"$s\\
",f($x-1,"$s "),"$s/
";}

Try it online!

Recursive in PHP.

-12 bytes by @manatwork

answered Jun 17, 2019 at 18:40
\$\endgroup\$
2
  • 1
    \$\begingroup\$ Better count down. Try it online!. \$\endgroup\$ Commented Jun 17, 2019 at 19:05
  • \$\begingroup\$ @manatwork very very nice! \$\endgroup\$ Commented Jun 17, 2019 at 19:11
1
\$\begingroup\$

\/\/>, 74 bytes

jp100o
-84*}!o:?!x1
@+:q:p=?x:o~$:0(pa"\/"q?$~}}:
x2-:p1ドル-y$:0(?
.{suh?!;2

Explanation: (lines rotated based on start point)

jp100o //setup
:?!x1-84*}! //add leading spaces, loop and decrement until 0
~$:0(pa"\/"q?$~}}:@+:q:p=?x:o //add correct slash, go back to loop or switch sides
$:0(?x2-:p1ドル-y //flip direction state or continue to print
{suh?!;2. //remove extra data and print stack
answered Jul 5, 2019 at 5:11
\$\endgroup\$
2
  • 1
    \$\begingroup\$ \/\/> (pronounced wɜrm) Thanks, I hate it. (jk, I'm looking forward to giving it a try) \$\endgroup\$ Commented Jul 5, 2019 at 6:39
  • \$\begingroup\$ @JoKing hahaha, gotta wear my inspiration on my sleeve. (thanks!) \$\endgroup\$ Commented Jul 5, 2019 at 6:42
1
\$\begingroup\$

Python 3, 55 bytes

f=lambda n,i="":n and i+"\\\n"+f(n-1,i+" ")+i+"/\n"or""

Try it online!

answered Oct 14, 2019 at 3:53
\$\endgroup\$
1
  • \$\begingroup\$ 54 bytes. \$\endgroup\$ Commented Oct 15, 2019 at 0:27
1
\$\begingroup\$

Erlang (escript), 69 bytes

Port of xnor's Python answer.

r(0,_)->"";r(I,X)->X++"\\\n"++r(I-1,X++" ")++X++"/\n".
r(I)->r(I,"").

Try it online!

answered Mar 25, 2020 at 7:42
\$\endgroup\$
1
2

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.