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.