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 code-golf so shortest code wins! Good luck,
13
Wikipedia calls the
– Stephen – 2017-09-20T19:16:58.067S
the Cool S, and calls an infinite version of the anS Chain
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