Draw An ASCII Double Helix Write a program that takes in an integer N via stdin or the command line.

If N is 0, the single letter O must be printed to stdout.



If N is positive, this horizontal ASCII art double helix, drawn N segments wide, must be printed.

If N is 1, the output is:

 /\
O  O
 \/


If N is 2, the output is:

 /\ /\
O  /  O
 \/ \/


If N is 3, the output is:

 /\ /\ /\
O  /  /  O
 \/ \/ \/


If N is 4, the output is:

 /\ /\ /\ /\
O  /  /  /  O
 \/ \/ \/ \/


The pattern continues in the exact same way for larger N. Note that forward slash (/) must be used in all places the helixes cross, except for the O ends.



If N is negative, this vertical ASCII art double helix, drawn -N segments tall, must be printed.

If N is -1, the output is:

 O
/ \
\ /
 O


If N is -2, the output is:

 O
/ \
\ /
 \
/ \
\ /
 O


If N is -3, the output is:

 O
/ \
\ /
 \
/ \
\ /
 \
/ \
\ /
 O


If N is -4, the output is:

 O
/ \
\ /
 \
/ \
\ /
 \
/ \
\ /
 \
/ \
\ /
 O


The pattern continues in the exact same way for smaller N. Note that backward slashes (\) must be used in all places the helixes cross, except for the O ends.

Details


Instead of a program, you may write a function that takes N as an integer and prints the result normally or returns it as a string.
The output for any N may optionally contain a trailing newline.
Any line of output for any N may optionally contain 4 or fewer trailing spaces.
There should never be any leading space that aren't part of the specified pattern.
The shortest code in bytes wins.
CJam, 56 55 53 52 50 bytes
S'O:Ori:X0&gt;&quot;\/&quot;=&quot; / \\\ / &quot;+Xz*1&gt;O]s3/X&quot;z&quot;&lt;~N*X\O?

Look at that size! The main culprits are N = 0 special case and the \ instead of / in the vertical helix.
Here is how it works:
S'O:O                                  e# Put a space on stack. Now put char O on stack
                                       e# and assign it to variable O. This is not really
                                       e# helping in golfing as using 'O everywhere is
                                       e# same number of bytes
     ri:X                              e# Read input as in integer and store it in X
         0&gt;&quot;\/&quot;=                       e# If X is greater than 0, choose /, otherwise \
                &quot; / \\\ / &quot;            e# Put this string on stack
                           +           e# Append to chosen \ or /
                            Xz*        e# Repeat it abs(X) times
1&gt;                                     e# Remove the first character from repeated string
  O]                                   e# Put char O on stack, wrap everything in an array
                                       e# and convert it to string.
    3/                                 e# Split the string into parts of length 3
      X&quot;z&quot;&lt;~                           e# If X is positive, transpose the array to get a
                                       e# horizontal helix, otherwise it would be vertical
            N*                         e# Join the parts with newline
              X\O?                     e# If X was 0, then pick char O instead of this
                                       e# final joined string.

The code is divided into three parts:

The part X0&gt;&quot;\/&quot;=&quot; / \\\ / &quot;+ gives either &quot;/ / \\\ / &quot; or &quot;\ / \\\ / &quot; which is crucial as the helix is simply made up of alternate &quot;/ \&quot; and &quot;\ /&quot; joined by either &quot; / &quot; or &quot; \ &quot;. For instance, if you consider input to be 2, then your final repeated string would be &quot;/ / \\ / / / \\ / &quot; (without escaping). This obviously has extra /  at the beginning and an extra space at the ending.
Second part is to correct the above string with additional things and split. For an input 2, the desired final string without newlines would be &quot; O / \\\ / / / \\\ / O&quot;, but after the above point, we only have &quot;/ / \\\ / / / \\\ / &quot;. So we remove the first character, add a space and 'O at the beginning and another 'O at the end. Then we finally split it into parts of 3
Finally, we decide whether to transpose this split string for a vertical helix or not; Join the parts by newlines; And choose between this and a single character 'O (for input 0 case)

Try it online here