Background

When I was younger, I was taught a method of drawing a weird "S" shape, that I (along with my classmates) found fascinating. Today, I rediscovered it, and due to its formulaic approach to drawing it, thought it could lead to an interesting challenge :P

Drawing the "S"

The S can be drawn by following these simple steps:

First, draw 2 rows of three vertical lines like so

| | |

| | |


Next, connect the top left line with the bottom middle line and the top middle with the bottom right line to produce

| | |
\ \
| | |


Finally, draw a top and bottom on the currently drawn image so that it ends up looking like

  ^
/ \
| | |
\ \
| | |
\ /
v


As you can see, this results in an "S" shape. When extended however (drawing it with more than 2 rows), it produces a very interesting pattern. Your task is reproduce this interesting pattern.

Given an integer where n >= 2, output The S with n rows to be made from it. Output may be returned from a function, and input may be taken in standard methods. Trailing/leading whitespace for both the overall image, as well as each line, is fine. However, leading line spaces must be consistent so that the " isn't broken. You may output as a list of lines.

Test cases

input
output
---

2

^
/ \
| | |
\ \
| | |
\ /
v

---

8
^
/ \
| | |
\ \
| | |
\ \
| | |
\ \
| | |
\ \
| | |
\ \
| | |
\ \
| | |
\ \
| | |
\ /
v

---

10

^
/ \
| | |
\ \
| | |
\ \
| | |
\ \
| | |
\ \
| | |
\ \
| | |
\ \
| | |
\ \
| | |
\ \
| | |
\ \
| | |
\ /
v


This is a so shortest code wins! Good luck,

• Wikipedia calls the S the Cool S, and calls an infinite version of the an S Chain – Stephen Sep 20 '17 at 19:16
• Can we output as a list of lines? – Mr. Xcoder Sep 20 '17 at 19:17
• @Mr.Xcoder you may – caird coinheringaahing Sep 20 '17 at 19:17
• @Stephen 10 minutes googling and this didn't come up. I'll edit the name of the question – caird coinheringaahing Sep 20 '17 at 19:18
• @cairdcoinheringaahing I searched images, that might have been it :P – Stephen Sep 20 '17 at 19:19

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
1
\¶| | |¶ \
^
^¶ /
$/¶ v  Try it online! I must be missing something, this is a super basic approach... • You did only outgolf Martin by 1 byte, so you probably aren't missing something – caird coinheringaahing Oct 4 '17 at 12:57 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.  • Nice job outgolfing Mego in his own language! – caird coinheringaahing Oct 4 '17 at 13:46 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.  • “\|||\”ẋ“ ^ /“/ v”jKs5Y – Erik the Outgolfer Oct 4 '17 at 14:29 Charcoal, 25 bytes ↘^\¶/¶Ｇ→⁵↓⊕⊗Ｎ←⁵|¶ \↗¶\¶v/  Try it online! Link is to verbose version of code. • Funny how the other Charcoal answer is the same byte-count by using an completely different approach. I like yours more, though. The other is close to hard-coded, but yours is actually using Charcoal's strength. – Kevin Cruijssen Oct 27 '17 at 12:13 • @KevinCruijssen You say strength, but that should really be printing diagonally; sadly the best I could do there was 29 bytes: ↘^\|¶/|\|¶|Ｆ⊖Ｎ↘\|\|¶|↘\|/¶|\v – Neil Oct 27 '17 at 13:48 PHP, 73 bytes <?=' ^ / \ '.join(' \ \ ',array_fill(0,$argv[1],'| | |')).'
\ /
v';


Try it online!

J, 51 50 48 bytes

'  v',~'  ^','/'(0 1;_1 3)}' \ \ | | |'$~5,~1++:  Try it online! 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 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

; Push the final 2 rows
push " \\ /\n  v"

; Append them

; Print the result string on the stack
print
ret
end


Pyth, 28 bytes

jcjd++" ^ /"*Q"\|||\\""/ v"5


Test suite

Canvas, 22 bytes

| | |¶\ \＊ｋ^¶/ \：↕└∔∔ｒ


Try it here!

Explanation:

Code                       # Explanation               # Stack visualization
#############################################################################################
# Stack starts with input   # <input>
| | |¶\ \                  # Push string literal       # <input>, | | |¶\ \
＊                # Repeat vertically n times # | | |¶\ \...| | |¶\ \
ｋ              # Remove last line          # | | |¶\ \...| | |
^¶/ \         # Push string literal       # | | |¶\ \...| | |, ^¶/ \
：       # Duplicate TOS             # | | |¶\ \...| | |, ^¶/ \, ^¶/ \
↕      # Mirror vertically         # | | |¶\ \...| | |, ^¶/ \, \ /¶v
└     # Swap 2nd and 3rd in stack # ^¶/ \, | | |¶\ \...| | |, \ /¶v
∔    # Add vertically            # ^¶/ \, | | |¶\ \...| | |¶\ /¶v
∔   # Add vertically            # ^¶/ \¶| | |¶\ \...| | |¶\ /¶v
ｒ # Center each line          #   ^¶ / \¶| | |¶ \ \...| | |¶ \ /¶  v
# Print TOS                 #


¶ represents a newline in the stack visualization.

05AB1E, 22 bytes

…\||û×" ^ /ÿ/ v"Sðý5ô»


Try it online!

…\||û×" ^ /ÿ/ 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


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


GolfScript, 46 bytes

~['
| | |
']*' \\'2**' \\ /
v'+
'  ^
/ \\'\
`

Try it online!