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.

  1. Use nested loops for size x size.
  2. If the sum of indices i + j is even, print 0.
  3. If the sum of indices i + j is odd, print 1.
  4. Spacing: print values in a row separated by spaces.

01EXAMPLE 1

Inputsize = 3
Output0 1 0 1 0 1 0 1 0

Explanation: Alternating cells.

Constraints

  • Correct row-by-row new lines.
  • Single space between column values.
MathLoops
JavaScript
Loading...
2 Hidden

Input Arguments

size3

Expected Output

0 1 0
1 0 1
0 1 0

Click RUN to test your solution