Given as input a positive integer n>=1
, output the first n
rows of the following triangle:
1
1 0 1
0 0 1 0 0
1 1 1 0 1 1 1
0 0 0 0 1 0 0 0 0
1 1 1 1 1 0 1 1 1 1 1
0 0 0 0 0 0 1 0 0 0 0 0 0
1 1 1 1 1 1 1 0 1 1 1 1 1 1 1
0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0
1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1
The rows alternate between all zeroes and all ones, except the center column is flipped.
Test cases
Input:
3
Output:
1 1 0 1 0 0 1 0 0
Input:
10
Output:
1 1 0 1 0 0 1 0 0 1 1 1 0 1 1 1 0 0 0 0 1 0 0 0 0 1 1 1 1 1 0 1 1 1 1 1 0 0 0 0 0 0 1 0 0 0 0 0 0 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1
Your code must work for any n<100
. This is code-golf, hence the shortest code in bytes wins!
Trailing spaces / newlines and leading newlines are allowed!