The Checkerboard Pulse
EasyAcc. 96.2%
+15 XP 5
Binary Alternation
A checkerboard pattern is a grid where values alternate at every step. Row 0: 0 1 0 1 Row 1: 1 0 1 0
The Assignment
Your function receives a parameter size.
- Use nested loops for
size x size. - If the sum of indices
i + jis even, print 0. - If the sum of indices
i + jis odd, print 1. - Spacing: print values in a row separated by spaces.
01EXAMPLE 1
Input
size = 3Output
0 1 0
1 0 1
0 1 0Explanation: Alternating cells.
Constraints
- Correct row-by-row new lines.
- Single space between column values.
MathLoops
JavaScriptSystem handles I/O — write your function only
Loading...
2 Hidden
Input Arguments
size3
Expected Output
0 1 0 1 0 1 0 1 0
Click RUN to test your solution