Draw an S-Chain

27

3

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.

Task

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,

caird coinheringaahing

Posted 2017-09-20T19:12:19.113

Reputation: 13 702

13

Wikipedia calls the S the Cool S, and calls an infinite version of the an S Chain

– Stephen – 2017-09-20T19:16:58.067

Can we output as a list of lines? – Mr. Xcoder – 2017-09-20T19:17:26.313

@Mr.Xcoder you may – caird coinheringaahing – 2017-09-20T19:17:59.703

@Stephen 10 minutes googling and this didn't come up. I'll edit the name of the question – caird coinheringaahing – 2017-09-20T19:18:53.250

@cairdcoinheringaahing I searched images, that might have been it :P – Stephen – 2017-09-20T19:19:24.390

I guess that leading spaces which break the shape of the S aren't allowed, right? – Erik the Outgolfer – 2017-09-20T19:20:55.843

@EriktheOutgolfer yes, I'll edit that in – caird coinheringaahing – 2017-09-20T19:21:15.807

There are probably better UTF-8 chars to display the cool S, especially than v and ^. – Eric Duminil – 2017-09-21T12:02:17.253

@EricDuminil yes, but they are most likely multi byte characters, which I'm reluctant to add as it means that languages that don't support those characters can't do the challenge as succinctly – caird coinheringaahing – 2017-09-21T14:07:23.923

@cairdcoinheringaahing: Fair point. – Eric Duminil – 2017-09-21T14:10:43.983

Answers

15

Python 2, 47 bytes

lambda k:'  ^\n / '+'\\\n| | |\n \ '*k+'/\n  v'

Try it online!

Lynn

Posted 2017-09-20T19:12:19.113

Reputation: 55 648

10

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"

Try it online!

my pronoun is monicareinstate

Posted 2017-09-20T19:12:19.113

Reputation: 3 111

1If this was a golf of the existing C# answer, I'd never have been able to tell. Well done :-) – ETHproductions – 2017-09-21T03:08:55.893

Can you explain what the new string[n+1] does? I have never seen it before. – Ian H. – 2017-09-21T07:39:06.387

Creates a array of empty strings AFAIK. I've used a hack with string.Join, aka join {"","","",""} with separator "\ \n | | | \n " – my pronoun is monicareinstate – 2017-09-21T07:40:59.627

@someone Woah, I never acknowledged this trick before. Really cool! (Also my bad, i though the new string[n+1] was some kind of tricky string constructor and not an array declaration -.-) – Ian H. – 2017-09-21T08:35:48.847

6

SOGL V0.12, 26 25 18 bytes

°I-‘*"∑ūCƨΩ)¹‘@∑5n

Try it Here!

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

dzaima

Posted 2017-09-20T19:12:19.113

Reputation: 19 048

2push "|" and " " what the heck is that builtin – Steven H. – 2017-09-20T19:35:49.643

1@StevenHewitt those are actually two built-ins, but I joined them together (as I do with other stuff) because I don't think it's not necessary to separate stuff that gets used together soon – dzaima – 2017-09-20T19:37:46.140

6

Python 3, 48  56 59 61  bytes

lambda k:'  ^\n / %s/\n  v'%('\\\n| | |\n \ '*k)

Try it online!

Mr. Xcoder

Posted 2017-09-20T19:12:19.113

Reputation: 39 774

You can save 2 bytes by unescaping the lone backslashes. – L3viathan – 2017-09-20T19:27:08.063

@L3viathan Just updating too – Mr. Xcoder – 2017-09-20T19:27:39.677

56 bytes; not sure if this is fair game; doesn't work on TIO – L3viathan – 2017-09-20T19:36:00.663

@L3viathan That is not correct. Extra \ \. – Mr. Xcoder – 2017-09-20T19:36:39.350

On TIO: yes. In my terminal: no. – L3viathan – 2017-09-20T19:37:08.137

@L3viathan I'll stick with my current solution, thanks though! – Mr. Xcoder – 2017-09-20T19:37:36.050

6

05AB1E, 27 26 bytes

…^
/ð"\
| | |
\ "I×…/
vJ.c

Try it online!

Alternate 27 byte version

'^…/ \©IF…| |û…\ \}\®R'v».c

Try it online!

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

Emigna

Posted 2017-09-20T19:12:19.113

Reputation: 50 798

5Your code looks a bit like an elephant to me :) – Wojowu – 2017-09-21T10:58:53.793

It's literally SCARY how close my answer was to yours: '^…/ \©IF„| ûû„\ û}\®R'v).C without looking. – Magic Octopus Urn – 2017-09-21T15:48:27.810

6

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"

ETHproductions

Posted 2017-09-20T19:12:19.113

Reputation: 47 880

Beating Charcoal and tying SOGL? Excellent work! – Shaggy – 2017-09-21T09:30:24.200

You can output an array of lines, by the way, so you can ditch the last 2 characters. – Shaggy – 2017-09-21T10:46:19.957

@Shaggy That's great, now we're winning! – ETHproductions – 2017-09-21T17:24:03.620

We've been doing well lately :) – Shaggy – 2017-09-22T10:40:29.317

5

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>

Justin Mariner

Posted 2017-09-20T19:12:19.113

Reputation: 4 746

157: n=>' ^\n /${' \\ \\\n| | |\n'.repeat(n).slice(2)} \\ /\n v' (using backticks and literal newlines) – edc65 – 2017-09-21T09:15:24.213

5

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

totallyhuman

Posted 2017-09-20T19:12:19.113

Reputation: 15 378

1

You can save 1 byte by just calling Print (instead of adding the strings) and using \r: ^⸿ / ×\⸿| | |⸿ \ Iθ/⸿ v. Verbose version.

– Charlie – 2017-09-21T07:09:27.387

Ah... I'll have to remember \r as the way to get newlines the sane way. Thanks! – totallyhuman – 2017-09-21T15:43:38.767

25 bytes – ASCII-only – 2017-10-04T11:25:45.537

@ASCII-only :P - – totallyhuman – 2017-10-04T12:54:47.107

4

Perl 5, 39 37 bytes

say"  ^
 / ".'\
| | |
 \ 'x<>."/
  v"

Try it online!

Shaved two bytes with @DomHastings' suggestion

Xcali

Posted 2017-09-20T19:12:19.113

Reputation: 7 671

If you use single quotes, you don't need to escape the backslashes for -2! :) – Dom Hastings – 2017-10-27T12:41:03.987

3

Actually, 49 bytes

"| | |"@α;lD" \ \"@α@Z♂ii"  v"" \ /"))" / \""  ^"

Try it online!

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

Mego

Posted 2017-09-20T19:12:19.113

Reputation: 32 998

3

05AB1E, 38 bytes

…| |ûU"  ^
 / \"XI<F„ \2×X}" \ /
  v"»

Try it online!

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

Riley

Posted 2017-09-20T19:12:19.113

Reputation: 11 345

3

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";}

Try it online!

As per usual, string repeating in C# is a pain.

Ian H.

Posted 2017-09-20T19:12:19.113

Reputation: 2 431

77 bytes. – totallyhuman – 2017-09-20T21:54:57.980

@icrieverytim Ahhh, of course, thats way better. – Ian H. – 2017-09-21T07:39:10.803

You can change --n>=0 to n-->0 and s+="/\n v";return s; to return s+"/\n v"; to save some bytes. – Kevin Cruijssen – 2017-09-21T07:54:50.810

1@KevinCruijssen Thanks, fixed! – Ian H. – 2017-09-21T09:15:51.030

3

C (gcc), 82 bytes

f(n){for(puts("  ^\n / \\");--n;puts("| | |\n \\ \\"));puts("| | |\n \\ /\n  v");}

Try it online!

cleblanc

Posted 2017-09-20T19:12:19.113

Reputation: 3 360

3

Retina, 38 bytes

.+
$*
1
¶|||¶x\\
^
 ^¶x/\
.$
/¶ v
x?
 

Try it online!

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.

Martin Ender

Posted 2017-09-20T19:12:19.113

Reputation: 184 808

Neat approach. I was trying to figure out a way to use join-on-spaces for my Pip solution, but it didn't quite work due to the different numbers of leading spaces on different rows. – DLosc – 2017-09-21T16:21:00.710

2

Pyth, 46 bytes

"  ^
 / \\"
+*j[jd*\|3" \ \\"k))Q" \ /
  v

Test suite.

Steven H.

Posted 2017-09-20T19:12:19.113

Reputation: 2 841

36 bytes: %" ^\n / %s/\n v"*Q"\\\n| | |\n \ – Mr. Xcoder – 2017-09-20T20:05:17.163

31 bytes. – Mr. Xcoder – 2017-09-20T20:11:01.053

2

Pyth, 40 bytes

K" / \ ""  ^"Kj+b+*2+d\\b*Q]*3"| "_K"  v

Fairly similar to Steven Hewitt's, but developed independently.

Try it Online

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.

user48543

Posted 2017-09-20T19:12:19.113

Reputation:

2

Pyth, 33 32 31 bytes

Thanks Mr. Xcoder for one byte.

%"  ^
 / %s/
  v"*tj\|_B" \\
| 

Try it online: Demonstration or Test Suite

Jakube

Posted 2017-09-20T19:12:19.113

Reputation: 21 462

Very nice answer! You can bring it down to 32 bytes.

– Mr. Xcoder – 2017-09-20T20:07:14.487

231 bytes, in fact. – Mr. Xcoder – 2017-09-20T20:07:41.007

2

Retina, 45 bytes

This is a pretty simple solution.

.+
$*
^1
  ^¶ /x
$
 \ /¶  v
1
 \x
x
 \¶| | |¶

Try it online

If the art could be 1-indexed instead, it'd be a bit shorter (44 bytes):

.+
  ^¶ /x$0$*1
$
 \ /¶  v
1
 \x
x
 \¶| | |¶

mbomb007

Posted 2017-09-20T19:12:19.113

Reputation: 21 944

2

Pip, 45 42 33 bytes

"  ^
 / "."\
| | |
 \ "Xa."/
  v"

Try it online!

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.)

DLosc

Posted 2017-09-20T19:12:19.113

Reputation: 21 213

This looks like Lumpy Space Princess from Adventure Time :)

– YSC – 2017-09-21T15:30:53.817

2

MATL, 47 44 43 bytes

-3 bytes thanks to Giuseppe

'  ^' ' / \ 'XK'| | |'XJGq:"' \'thJ]KP'  v'

Try it online!

Cinaski

Posted 2017-09-20T19:12:19.113

Reputation: 1 588

' ^' ' / \ 'XK'| | |'XJ\' \ 'JGq@-]KP' v'` is 44 bytes. – Giuseppe – 2017-09-21T17:53:57.210

1

PowerShell, 83, 57 bytes

"  ^
 / \"
1..--$args[0]|%{"| | |
 \ \"}
"| | |
 \ /
  v"

Try it online!

Per @AdmBorkBork's suggestions,

  • Simplified for by using a number range.
  • Replaced ;'s and combined strings.
  • Removed an unnecessary variable definition.

root

Posted 2017-09-20T19:12:19.113

Reputation: 241

You can golf your for loop a lot by using 1..--$args[0]|%{ }.

– AdmBorkBork – 2017-09-21T12:34:19.490

Also, you can use literal newlines between the adjacent strings to save on ";" and it's cheaper to get rid of $s entirely. 57 bytes

– AdmBorkBork – 2017-09-21T12:40:49.700

Slick. I like the newline save. Funny that I missed the 1..$args opportunity. I'm not sure what the correct etiquette is on this site. Do I make changes to my answer and credit you, or do you post your solution as a separate answer? – root – 2017-09-21T13:09:39.650

Editing in the changes and giving credit is the proper etiquette. Welcome to PPCG. – AdmBorkBork – 2017-09-21T13:27:23.337

1

Haskell, 53 bytes

f n="  ^\n /"++([1..n]>>" \\\n| | |\n \\")++" /\n  v"

Try it online!

nimi

Posted 2017-09-20T19:12:19.113

Reputation: 34 639

1

Excel, 60 bytes

="  ^
 / \
"&REPT("| | |
 \ \
",A1-1)&"| | |
 \ /
  v"

Wernisch

Posted 2017-09-20T19:12:19.113

Reputation: 2 534

You should consider checking to see if this is a polyglot with Google Sheets – Taylor Scott – 2017-10-04T14:23:45.410

1

AsciiDots, 88 bytes

.*$"  ^"$" / \"
/>#?)--*$"| | |"$" \ \"
*#1\ /-~$"| | |"$" \ /"$"  v"
*-{-}*[<]
\#0----/

Try it online!

user31415

Posted 2017-09-20T19:12:19.113

Reputation: 141

1

Jelly, 32 bytes

Boring port of Lynn's Python solution.

“\¶| | |¶ \ ”ẋṭ“  ^¶ / ”;“/¶  v”

Try it online!

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

Comrade SparklePony

Posted 2017-09-20T19:12:19.113

Reputation: 5 784

1

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.

Sherlock9

Posted 2017-09-20T19:12:19.113

Reputation: 11 664

Nice job outgolfing Mego in his own language! – caird coinheringaahing – 2017-10-04T13:46:45.370

1

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.

Sherlock9

Posted 2017-09-20T19:12:19.113

Reputation: 11 664

“\|||\”ẋ“ ^ /“/ v”jKs5Y – Erik the Outgolfer – 2017-10-04T14:29:00.050

1

Charcoal, 25 bytes

↘^\¶/¶G→⁵↓⊕⊗N←⁵|¶ \↗¶\¶v/

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

Neil

Posted 2017-09-20T19:12:19.113

Reputation: 95 035

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 – 2017-10-27T12:13:48.070

@KevinCruijssen You say strength, but that should really be printing diagonally; sadly the best I could do there was 29 bytes: ↘^\|¶/|\|¶|F⊖N↘\|\|¶|↘\|/¶|\v – Neil – 2017-10-27T13:48:34.450

1

bash, 67 bytes

printf -v a %\*s $1 \ ;echo '  ^
 / '"${a// /\\
| | |
 \\ }"'/
  v'

Try it online

Nahuel Fouilleul

Posted 2017-09-20T19:12:19.113

Reputation: 5 582

0

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.

Try it here.

Kevin Cruijssen

Posted 2017-09-20T19:12:19.113

Reputation: 67 575

It's funny how this is almost exactly identical expect for the string vs var part. – Ian H. – 2017-09-21T08:34:31.637

@IanH. And the n-> vs n=> ;) – Kevin Cruijssen – 2017-09-21T09:11:27.657

0

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.

Brian

Posted 2017-09-20T19:12:19.113

Reputation: 1 209

0

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

steenbergh

Posted 2017-09-20T19:12:19.113

Reputation: 7 772

0

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 n times the chain body
  • Output the bottom of the Cool S

stevefestl

Posted 2017-09-20T19:12:19.113

Reputation: 539

0

R, 90 bytes

function(n){cat('  ^
 / \\
| | |
')
for(i in 2:n-1)cat(' \\ \\
| | |
')
cat(' \\ /
  v
')}

Try it online!

pretty lame, but this is the best we've got to work with in R.

Giuseppe

Posted 2017-09-20T19:12:19.113

Reputation: 21 077

0

Retina, 37 bytes

.*
$*
1
\¶| | |¶ \ 
^
  ^¶ / 
$
/¶  v

Try it online!

I must be missing something, this is a super basic approach...

totallyhuman

Posted 2017-09-20T19:12:19.113

Reputation: 15 378

You did only outgolf Martin by 1 byte, so you probably aren't missing something – caird coinheringaahing – 2017-10-04T12:57:46.240

0

Excel VBA, 72 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"

Taylor Scott

Posted 2017-09-20T19:12:19.113

Reputation: 6 709

0

Ruby, 39 bytes

->n{"  ^
 / #{"\\
| | |
 \\ "*n}/
  v"}

Try it online!

Jordan

Posted 2017-09-20T19:12:19.113

Reputation: 5 001

0

J, 51 bytes

'  v',~' \ /',~'  ^',' / \',[:}:'| | | \ \ '$~5,~+:

Try it online!

Jonah

Posted 2017-09-20T19:12:19.113

Reputation: 8 729

0

PHP, 73 bytes

<?='  ^
 / \
'.join('
 \ \
',array_fill(0,$argv[1],'| | |')).'
 \ /
  v';

Try it online!

Jo.

Posted 2017-09-20T19:12:19.113

Reputation: 974