# 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 Sep 20, 2017 at 19:16
• Can we output as a list of lines? Sep 20, 2017 at 19:17
• @Mr.Xcoder you may Sep 20, 2017 at 19:17
• @Stephen 10 minutes googling and this didn't come up. I'll edit the name of the question Sep 20, 2017 at 19:18
• @cairdcoinheringaahing I searched images, that might have been it :P Sep 20, 2017 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!

# 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!

# Vyxal, 24 bytes

\||∞* ^ /p/ v`JṄ5ẇ⁋

Try it Online!