| Bytes | Lang | Time | Link |
|---|---|---|---|
| 036 | Raku Perl 6 rakudo | 250417T174207Z | xrs |
| 080 | AWK | 250407T220242Z | xrs |
| 024 | Vyxal | 220527T033412Z | naffetS |
| 054 | /// | 210323T170546Z | Samuel W |
| 046 | GolfScript | 210323T165331Z | Samuel W |
| 071 | Excel VBA | 171004T142629Z | Taylor R |
| 022 | 05AB1E | 210321T192003Z | Makonede |
| 022 | Canvas | 210321T055209Z | hakr14 |
| 028 | Pyth | 210321T054042Z | hakr14 |
| 130 | CSASM v2.1.2.3 | 210321T041136Z | absolute |
| 076 | x86_16 machine code | 210317T002415Z | Febriyan |
| 020 | Stax | 210317T024530Z | Razetime |
| nan | J | 171028T031301Z | Jonah |
| 073 | PHP | 171028T070931Z | Jo. |
| 037 | Perl 5 | 170920T212340Z | Xcali |
| 039 | Ruby | 171027T185542Z | Jordan |
| 067 | bash | 171027T115533Z | Nahuel F |
| 025 | Charcoal | 171027T111552Z | Neil |
| 023 | Jelly | 171004T141812Z | Sherlock |
| 030 | Actually | 171004T134351Z | Sherlock |
| 037 | Retina | 171004T125529Z | totallyh |
| 025 | Charcoal | 170920T213837Z | totallyh |
| 090 | R | 170926T214904Z | Giuseppe |
| 032 | Jelly | 170926T212723Z | sporkl |
| 043 | MATL | 170921T164656Z | Cinaski |
| 088 | AsciiDots | 170924T213226Z | user3141 |
| 018 | SOGL V0.12 | 170920T192155Z | dzaima |
| 109 | Batch | 170923T011228Z | stevefes |
| 023 | Japt | 170921T013010Z | ETHprodu |
| 048 | QBIC | 170921T163055Z | steenber |
| 057 | PowerShell | 170920T205422Z | root |
| 062 | C# .NET Core | 170921T015724Z | the defa |
| 038 | Retina | 170921T114008Z | Martin E |
| 074 | SpecBAS | 170921T110415Z | Brian |
| 060 | Excel | 170921T103545Z | Wernisch |
| 073 | C# .NET Core | 170920T201725Z | Ian H. |
| 076 | Java 8 | 170921T075541Z | Kevin Cr |
| 033 | Pip | 170921T033920Z | DLosc |
| 082 | C gcc | 170920T203948Z | cleblanc |
| 053 | Haskell | 170920T205423Z | nimi |
| 026 | 05AB1E | 170920T203232Z | Emigna |
| 045 | Retina | 170920T203944Z | mbomb007 |
| 031 | Pyth | 170920T200424Z | Jakube |
| 038 | 05AB1E | 170920T200231Z | Riley |
| 040 | Pyth | 170920T194801Z | user4854 |
| 048 | Python 3 | 170920T192344Z | Mr. Xcod |
| 047 | Python 2 | 170920T192943Z | lynn |
| 060 | JavaScript ES6 | 170920T193921Z | Justin M |
| 046 | Pyth | 170920T193456Z | Steven H |
| 049 | Actually | 170920T192742Z | user4594 |
AWK, 80 bytes
{s=" ^\n / \\\n";for(c=(a="| | |\n")" \\ \\\n";++i<$1;)s=s c}$0=s a" \\ /\n v"
{s=" ^\n / \\\n"; # initialize string to top point
for(c= # create a block of two lines
(a="| | |\n") # first line
" \\ \\\n"; # second line
++i<$1;) # while less than input
s=s c} # append block to string
$0=s # set output to string
a # append end | | |
" \\ /\n v" # with bottom point
///, 54 bytes
/*/
| | |
b//b>///b/ \\\\ \\\\/ ^
\/ \\**> \\ \/
v
For input, change the number of asterisks
\/ \\**> \\ \/
^^
Excel VBA, 71 Bytes
Anonymous VBE immediate window function that takes input from cell A1 and outputs to the VBE immediate window
a="| | |":?" ^":?" / \":For i=2To[A1]:?a:?" \ \":Next:?a:?" \ /":?" v
05AB1E, 22 bytes
…\||û×" ^ /ÿ/ v"Sðý5ô»
…\||û×" ^ /ÿ/ v"Sðý5ô» # full program
» # split...
" ^ /ÿ/ v" # literal...
# (implicit) with ÿ replaced by...
…\|| # literal...
û # concatenated with...
…\|| # literal...
û # reversed excluding the first character...
× # repeated...
# implicit input...
× # times...
ý # with each...
S # character...
ý # joined by...
ð # spaces...
» # into rows...
ô # of length...
5 # literal
# implicit output
Canvas, 22 bytes
| | |¶\ \*k^¶/ \:↕└∔∔r
Explanation:
Code # Explanation # Stack visualization
#############################################################################################
# Stack starts with input # <input>
| | |¶\ \ # Push string literal # <input>, | | |¶\ \
* # Repeat vertically n times # | | |¶\ \...| | |¶\ \
k # Remove last line # | | |¶\ \...| | |
^¶/ \ # Push string literal # | | |¶\ \...| | |, ^¶/ \
: # Duplicate TOS # | | |¶\ \...| | |, ^¶/ \, ^¶/ \
↕ # Mirror vertically # | | |¶\ \...| | |, ^¶/ \, \ /¶v
└ # Swap 2nd and 3rd in stack # ^¶/ \, | | |¶\ \...| | |, \ /¶v
∔ # Add vertically # ^¶/ \, | | |¶\ \...| | |¶\ /¶v
∔ # Add vertically # ^¶/ \¶| | |¶\ \...| | |¶\ /¶v
r # Center each line # ^¶ / \¶| | |¶ \ \...| | |¶ \ /¶ v
# Print TOS #
¶ represents a newline in the stack visualization.
CSASM v2.1.2.3, 130 bytes
By far the shortest answer I'll submit with this language. (Probably)
Hooray for builtins!
func main:
in ""
conv i32
pop $a
push " ^\n / \\\n| | |\n"
push " \\ \\\n| | |\n"
push $a
push 1
sub
mul
add
push " \\ /\n v"
add
print
ret
end
Commented and ungolfed:
func main:
; Get the input, convert it to an integer and store it in the accumulator
in ""
conv i32
pop $a
; Push the first three rows of the chain
push " ^\n / \\\n| | |\n"
; Push the next two rows of the chain
push " \\ \\\n| | |\n"
; Duplicate those two rows ($a - 1) times
push $a
push 1
sub
mul
; Append the duplicated rows to the first three rows
add
; Push the final 2 rows
push " \\ /\n v"
; Append them
add
; Print the result string on the stack
print
ret
end
x86_16 machine code - 76 bytes
8B CB MOV CX, BX
49 DEC CX
B4 09 MOV AH, 09H
ATAS:
BA 02 01 MOV DX, OFFSET RANTAI_S_1
CD 21 INT 21H
85 C9 TEST CX, CX
74 09 JE BAWAH
.LOOP:
BA 15 01 MOV DX, OFFSET RANTAI_LOOP
CD 21 INT 21H
E3 02 JCXZ BAWAH
E2 F7 LOOP .LOOP
BAWAH:
BA 23 01 MOV DX, OFFSET RANTAI_S_2
CD 21 INT 21H
EXIT:
B8 00 4C MOV AX, 4C00H
CD 21 INT 21H
RANTAI_S_1 DB 020H, 020H, 05EH, 00AH, 00DH, 020H, 02FH, 020H, 05CH
DB 00AH, 00DH, 07CH, 020H, 07CH, 020H, 07CH, 00AH, 00DH
DB 024H
RANTAI_LOOP DB 020H, 05CH, 020H, 05CH, 00AH, 00DH, 07CH, 020H, 07CH
DB 020H, 07CH, 00AH, 00DH, 024H
RANTAI_S_2 DB 020H, 05CH, 020H, 02FH, 00AH, 00DH, 020H, 020H, 076H
DB 024H
Tested on DOSBox
Stax, 21 20 bytes
⌐èüYΩ╜yu╝√♪╪▌yº⌐▌2Σ⌠
Uses ETHProductions' idea.
-1 after changing 1/ to M (from recursive).
Jelly, 25 23 bytes
This works on the same principle as ETHproductions's Japt answer, where extra spaces are added later, and the whole string is split into strings of length 5 before printing. Try it online!
Edit: I knew there was a way to join the top and bottom of the S-chain in a golfier way. Thanks to Erik the Outgolfer for -2 bytes.
“\|||\”ẋ“ ^ /“/ v”jKs5Y
Ungolfing
Left argument: n
“\|||\”ẋ Repeat the middle portion n times.
“ ^ /“/ v”j Append the top and bottom.
K Join with spaces.
s5 Split into a list of length-5 strings.
Y Print the strings with linefeeds.
Actually, 30 bytes
This works on the same principle as ETHproductions's Japt answer, where extra spaces are added later, and the whole string is split into rows of 5 for implicit printing. Try it online!
"\|||\"*" ^ /"+"/ v"@+#' j5@╪i
Ungolfing
Implicit input.
"\|||\"* Add the middle portion and multiply that by the input.
" ^ /"+ Append the top.
"/ v"@+ Append the bottom.
# Convert into a list of strings
' j Join with spaces.
5@╪ Split into a list of length-5 strings.
i Flatten list onto the stack for implicit printing with newlines.
Retina, 37 bytes
.*
$*
1
\¶| | |¶ \
^
^¶ /
$
/¶ v
I must be missing something, this is a super basic approach...
Charcoal, 27 26 25 bytes
-1 byte thanks to Carlos Alejo. -1 byte thanks to ASCII-only.
^⸿ / ×\⸿| | |⸿ \ N/⸿ v
Try it online! Link is to verbose version. #charcoal-verbose-obfucation
R, 90 bytes
function(n){cat(' ^
/ \\
| | |
')
for(i in 2:n-1)cat(' \\ \\
| | |
')
cat(' \\ /
v
')}
pretty lame, but this is the best we've got to work with in R.
Jelly, 32 bytes
Boring port of Lynn's Python solution.
“\¶| | |¶ \ ”ẋṭ“ ^¶ / ”;“/¶ v”
Explanation:
“\¶| | |¶ \ ”ẋṭ“ ^¶ / ”;“/¶ v” Example input: 5
“\¶| | |¶ \ ” Literal string "\¶| | |¶ \ " (¶ = newline). Result: "\¶| | |¶ \ "
ẋ Repeat as many times as the (implicit) input. Result: "\¶| | |¶ \ \¶| | |¶ \ \¶| | |¶ \ \¶| | |¶ \ \¶| | |¶ \ "
ṭ Tack that on the end of...
“ ^¶ / ” ...the string " ^¶ / ". Result: " ^¶ / \¶| | |¶ \ \¶| | |¶ \ \¶| | |¶ \ \¶| | |¶ \ \¶| | |¶ \ "
; Append...
“/¶ v” The string "/¶ v". Result: " ^¶ / \¶| | |¶ \ \¶| | |¶ \ \¶| | |¶ \ \¶| | |¶ \ \¶| | |¶ \ /¶ v"
Implicit print
AsciiDots, 88 bytes
.*$" ^"$" / \"
/>#?)--*$"| | |"$" \ \"
*#1\ /-~$"| | |"$" \ /"$" v"
*-{-}*[<]
\#0----/
SOGL V0.12, 26 25 18 bytes
°I-‘*"∑ūCƨΩ)¹‘@∑5n
Uses the same strategy as ETHproductions's Japt answer
Explanation:
..‘ push "\|||\"
* repeat input times
"..‘ push " ^ /ŗ/ v ", with ŗ replaced with POP. The reason why there's a trailing
space is because otherwise it didn't have enough repeating characters to compress
@∑ join with spaces
5n split to line lengths of 5
Batch, 109 bytes
I believe this isn't completely golfed yet.
@echo ^^
@echo / \
@for /l %%G in (2,1,%1)do @echo ^| ^| ^|&@echo \ \
@echo ^| ^| ^|
@echo \ /
@echo v
This script just:
- Output the top of the Cool S
- Loop
ntimes the chain body - Output the bottom of the Cool S
Japt, 34 25 23 bytes
" ^ /{ç'\²i|³1}/ v"¬¸ò5
Test it online! Outputs as an array of lines; -R flag added to join on newlines. (Thanks @Shaggy)
First Second attempt, might be improvable...
How it works
" ^ /{ ç'\² i |³ 1}/ v"¬ ¸ ò5
" ^ /{Uç'\p2 i'|p3 1}/ v"q qS ò5 Ungolfed
Implicit: U = input number
'\p2 Repeat a backslash twice, giving "\\".
i 1 Insert at index 1
'|p3 3 vertical bars. This gives "\|||\".
Uç Make U copies of this string. U = 2: "\|||\\|||\"
" ^ /{ }/ v" Insert this into this string. " ^ /\|||\\|||\/ v"
q qS Split into chars; join on spaces." ^ / \ | | | \ \ | | | \ / v"
ò5 Split into rows of length 5. [" ^ "," / \ ","| | |"," \ \ ","| | |"," \ / "," v"]
Joining on newlines gives " ^
/ \
| | |
\ \
| | |
\ /
v"
QBIC, 48 bytes
?@ ^`?@ / \ `[:|?@| | |`~a=b|?_fB|?@ v`\?@ \ \
Explanation
Note that every '?' inserts a linebreak
Also note that @...` creates a string literal and assigns that to A$, B$, ... Z$
?@ ^` print ^ prefixed with 2 spaces
?@ / \ ` print the other start bit, pre- and postfixed with spaces
[:| FOR a = 1 to (chain-length given as cmd line param, read as 'b')
?@| | |` PRINT the pipes
~a=b| IF we are in the last iteration THEN
?_fB| print the reversed of B$
_f...| flips a string
B$ holds " / \ ", which reversed is " \ / "
?@ v` and print " v"
\ ELSE
?@ \ \ print the connector to the next section
The final string lit, the IF and the FOR are auto-closed at EOF
PowerShell, 83, 57 bytes
" ^
/ \"
1..--$args[0]|%{"| | |
\ \"}
"| | |
\ /
v"
Per @AdmBorkBork's suggestions,
- Simplified
forby using a number range. - Replaced
;'s and combined strings. - Removed an unnecessary variable definition.
C# (.NET Core), 73 69 66 64 62 bytes
Two less bytes and perl-like appearance thanks to Barodus. Didn't think of using int? for nulls.
n=>$@" ^
/ {string.Join(@"\
| | |
\ ",new int?[++n])}/
v"
Retina, 38 bytes
.+
$*
1
¶|||¶x\\
^
^¶x/\
.$
/¶ v
x?
Prints a column of leading spaces and on trailing space on each line.
Explanation
The main byte savings come from omitting the spaces in all the literal parts and inserting them at the end. The figure is structured such that there are never two non-spaces next to each other, so if we just remove them all, we can almost fix the shape by inserting a space at every position at the end:
^
/\
|||
\\
|||
\/
v
becomes:
^
/ \
| | |
\ \
| | |
\ /
v
That's almost correct, except for indentation. The ^ and v are missing two spaces. That's actually easier to fix, because if we just insert an explicit space in front of each of them, that'll result in two additional spaces at the end. The lines with the slashes are trickier because they require just one additional space. To fix this, we insert a placeholder character there (x). When we insert the spaces at the end, we don't just insert them for every empty match, but we optionally match that x. That means instead of inserting a space in front of the x, the x itself gets replaced. And then there will still be an empty match right after the x. That means, every x adds exactly one space without changing anything else. So what we want to set up is this:
^
x/\
|||
x\\
|||
x\/
v
which will give us the desired result. So here's the code:
.+
$*
Convert the input to unary.
1
¶|||¶x\\
Convert each 1 to two lines with ||| and x\\ (and a leading linefeed).
^
^¶x/\
Inser the first two lines with ^ and x/\.
.$
/¶ v
Fix the final x\\ by turning the last \ into / and appending a line with the v.
x?
Replace each x or empty match with a space.
SpecBAS - 74 bytes
1 INPUT n
2 ?" ^"'" / \"'("| | |"#13" \ \"#13)*(n-1);"| | |"'" \ /"'" v"
Apostrophe moves to next line, but doesn't work inside the string being repeated, so have to use #13 to insert line feeds in that part.
Excel, 60 bytes
=" ^
/ \
"&REPT("| | |
\ \
",A1-1)&"| | |
\ /
v"
C# (.NET Core), 101 77 73 bytes
Saved 24 bytes thanks to i cri everytim!
Saved 4 bytes thanks to Kevin Cruijssen!
n=>{var s=" ^\n / ";for(;n-->0;s+="\\\n| | |\n \\ ");return s+"/\n v";}
As per usual, string repeating in C# is a pain.
Java 8, 93 76 bytes
n->{String r=" ^\n / ";for(;n-->0;r+="\\\n| | |\n \\ ");return r+"/\n v";}
Port of @IanH.'s C# .NET answer after I golfed it a bit more.
Pip, 45 42 33 bytes
" ^
/ "."\
| | |
\ "Xa."/
v"
Explanation
The code is really simple, though the newlines make it harder to read. Here's a better way to see the structure:
"prefix" . "repeated" X a . "suffix"
The repeated element in the S-chain is
\
| | |
\
Take this as a literal string and repeat it a times (where a is the first command-line argument). Then prepend the prefix:
^
/
and append the suffix:
/
v
and print.
(I like how this ended up looking kinda like a ><> program.)
C (gcc), 82 bytes
f(n){for(puts(" ^\n / \\");--n;puts("| | |\n \\ \\"));puts("| | |\n \\ /\n v");}
05AB1E, 27 26 bytes
…^
/ð"\
| | |
\ "I×…/
vJ.c
Alternate 27 byte version
'^…/ \©IF…| |û…\ \}\®R'v».c
Explanation
'^ # push "^"
…/ \© # push "/ \" and store a copy in register
IF # input times do:
…| |û # push "| | |"
…\ \ # push "\ \"
} # end loop
\ # discard top of stack (the extra "\ \")
®R # push "/ \" reversed = "\ /"
'v # push "v"
» # join stack on newlines
.c # center each row
Retina, 45 bytes
This is a pretty simple solution.
.+
$*
^1
^¶ /x
$
\ /¶ v
1
\x
x
\¶| | |¶
If the art could be 1-indexed instead, it'd be a bit shorter (44 bytes):
.+
^¶ /x$0$*1
$
\ /¶ v
1
\x
x
\¶| | |¶
Pyth, 33 32 31 bytes
Thanks Mr. Xcoder for one byte.
%" ^
/ %s/
v"*tj\|_B" \\
|
Try it online: Demonstration or Test Suite
05AB1E, 38 bytes
…| |ûU" ^
/ \"XI<F„ \2×X}" \ /
v"»
…| | # Push "| |"
û # Palindromize
U # Store in X
"..."X # Push the top three rows
I<F } # One less than input times do:
„ \ # Push " \"
2× # Concatenate that with itself
X # Push "| | |"
"..." # Push the last two rows
» # Join stack with newlines
Pyth, 40 bytes
K" / \ "" ^"Kj+b+*2+d\\b*Q]*3"| "_K" v
Fairly similar to Steven Hewitt's, but developed independently.
Explanation
K" / \ "" ^"Kj+b+*2+d\\b*Q]*3"| "_K" v
K" / \ "" Set K = " / \ "
" ^" " v Draw the end points.
K _K Draw the slants.
*Q]*3"| " Draw the vertical bars...
j+b+*2+d\\b ... interspersed with slants.
JavaScript (ES6), 60 bytes
n=>` ^
/ \\
${`| | |
\\ \\
`.repeat(n-1)}| | |
\\ /
v`
Test Snippet
let f=
n=>` ^
/ \\
${`| | |
\\ \\
`.repeat(n-1)}| | |
\\ /
v`
;(I.oninput=_=>O.innerHTML=I.value+"\n"+f(+I.value))()
<input id=I type=range min=2 max=15 value=2><pre id=O></pre>
Actually, 49 bytes
"| | |"@α;lD" \ \"@α@Z♂ii" v"" \ /"))" / \"" ^"
Explanation:
"| | |"@α;lD" \ \"@α@Z♂ii" v"" \ /"))" / \"" ^"
"| | |"@α push a list containing n copies of the vertical lines
;lD" \ \"@α push a list containing n-1 copies of the diagonal connections
@Z♂i interleave
i flatten
" v"" \ /")) make the bottom
" / \"" ^" make the top


