9.1.7 Checkerboard V2 Codehs
In the exercise on CodeHS, you create a checkerboard pattern by utilizing a for loop to iterate through a 2D array (grid) and assigning colors based on whether the sum of the row and column indices is even or odd. 1. Initialize the grid
if (row % 2 == 0) // normal parity else // shifted: (col % 2 == 0) gives opposite 9.1.7 Checkerboard V2 Codehs
to form a checkerboard pattern. Unlike Version 1, which might only change specific rows, Version 2 tests your ability to use nested loops and logic to handle the alternating pattern across the entire board. Core Logic for Checkerboard V2 The key to this exercise is the modulus operator ( In the exercise on CodeHS, you create a
: Using getWidth() and getHeight() ensures your checkerboard fills the entire canvas regardless of the window size. Unlike Version 1, which might only change specific