⏱ 00:00
Attempts:0
Best: 0/100
Binary & Alternating LogicTarget Time: 10 mins
0-1 Triangle
Given an integer N, print a 0-1 triangle pattern where the element at row i and column j is 1 if (i + j) is even, and 0 if (i + j) is odd. Elements in a row are separated by a space.
Input Format
A single integer N.
Output Format
Print N rows with alternating 1 and 0 values.
Constraints:1 <= N <= 20
Concepts Required:
Parity check ((i + j) % 2 == 0)Chessboard / checkerboard pattern logic
Expected Pattern PreviewASCII Monospace
1 0 1 1 0 1 0 1 0 1 1 0 1 0 1
Notice how character spacing and row counts scale systematically based on the input N.
Concrete Examples
Example 1
Input:
5
Output:
1 0 1 1 0 1 0 1 0 1 1 0 1 0 1
Explanation: At (1, 1), 1+1=2 (even) -> 1. At (2, 1), 2+1=3 (odd) -> 0, etc.
