29
6
You will be given a positive integer N
as input. Your task is to build a Semi-Zigzag, of N
sides, each of length N
. Since it is relatively hard to clearly describe the task, here are some examples:
N = 1
:O
N = 2
:O O O
N = 3
:O O O O O O O
N = 4
:O O O O O O O O O O O O O
N = 5
:O O O O O O O O O O O O O O O O O O O O O
N = 6
:O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O
N = 7
:O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O
As you can see, a Semi-Zigzag is made of alternating diagonal and horizontal lines, and it always begins with a top-left to bottom right diagonal line. Take note that the characters on the horizontal lines are separated by a space.
Rules
You may choose any non-whitespace character instead of
O
, it may even be inconsistent.You may output / return the result as a String or as a list of Strings, each representing one line.
You may have a trailing or leading newline.
Default Loopholes apply.
You can take input and provide output by any standard mean.
If possible, please add a testing link to your submission. I will upvote any answer that shows golfing efforts and has an explanation.
This is code-golf, so the shortest code in bytes in every language wins!
1Sandbox Post. – Mr. Xcoder – 2017-07-30T11:02:43.890
Do we have to put spaces between O that are horizontal ? – HatsuPointerKun – 2017-07-30T13:27:22.970
1@HatsuPointerKun Take note that the characters on the horizontal lines are separated by a space. – Yes, you do have to put spaces. – Mr. Xcoder – 2017-07-30T13:28:07.133
1Ah, yes. I should learn to read. Thanks – HatsuPointerKun – 2017-07-30T13:37:07.720
What is the highest number test case? Haven't tried all the answers but they seem to get borked at anything that a screen can't take from one side to the other. (i.e. 15) – John Hamilton – 2017-07-31T11:26:41.853
1@JohnHamilton The answers should theoretically work for any number given as input. They must not worry about what a screen can hold. – Mr. Xcoder – 2017-07-31T11:42:05.893