9.1.7 Checkerboard V2 Codehs

: Users often try to build a "1,0,1,0" list and a "0,1,0,1" list and append them alternately. While this works for the visual output, it may bypass the lesson's goal of teaching index-based assignment. Indentation Errors

: Pay close attention to whether the top-left cell [0][0] needs to be a 0 or a 1 . If your pattern is perfectly inverted, simply flip the logic inside your if-else statement.

A checkerboard requires adjacent squares to have different values. If you look closely at the coordinates of a checkerboard, a clear mathematical pattern emerges: Column Index Sum (Row + Col) Pattern Value Color A (or 1) Color B (or 0) Color B (or 0) Color A (or 1)

The most efficient way to solve a checkerboard problem is by using the . 9.1.7 Checkerboard V2 Codehs

Notice that all adjacent squares alternate between even and odd sums. By checking if (row + col) % 2 == 0 , your program can perfectly alternate colors across the entire board. Pseudo-code and Structural Breakdown

N = 8 squareSize = 50 setCanvasSize(N * squareSize, N * squareSize)

If your code is not passing the CodeHS autograder, check the following: : Users often try to build a "1,0,1,0"

How do you make colors switch? A common mistake is alternating based only on the column, which makes stripes, not a checkerboard.

add(square);

You must correctly calculate the (x, y) position of each rectangle based on the current row and column, taking into account the size of the squares. Detailed Logic Breakdown (Step-by-Step) If your pattern is perfectly inverted, simply flip

To solve 9.1.7 Checkerboard V2 , you need to be comfortable with these four pillars:

Completing the Checkerboard v2 exercise solidifies your understanding of constructing structured, tabular data. It's a fantastic way to apply fundamental programming concepts like loops, conditionals, and data structures to solve a visual and logical problem. If you run into issues, remember to use the print statements for debugging and to leverage the CodeHS documentation to break down unfamiliar parts of the code.