9.1.7 Checkerboard V2 Codehs 2021 Jun 2026
These skills reappear in game development (chess, tic-tac-toe), image processing (pixel patterns), and data visualization (heatmaps).
❌ Using two separate loops for colors. ❌ Forgetting to set the fill color before adding the rectangle. ❌ Off-by-one errors in the loop conditions. ❌ Hardcoding square size and board dimensions without using constants.
Think of the board as a grid. You need to iterate over each row, and within each row, over each column.
: Iterate through the rows and columns. Use an if statement with the modulo operator to check the indices.
In CodeHS graphics (using the GraphicsProgram or Turtle ), you will use add(new Rectangle(x, y, width, height)) or similar methods. 9.1.7 Checkerboard V2 Codehs
If the row index is even, the pattern might start with Color A.
This public link is valid for 7 days and shares a thread, including any personal information you added. This link or copies made by others cannot be deleted. If you share with third parties, their policies apply. Can’t copy the link right now. Try again later.
const readline = require('readline'); const rl = readline.createInterface( input: process.stdin, output: process.stdout );
Start by defining the size of your board and the colors you want to use. This makes your code easier to read and modify later. javascript ❌ Off-by-one errors in the loop conditions
GRect square = new GRect(x, y, SQUARE_SIZE, SQUARE_SIZE); square.setFilled(true);
add(square);
square.setColor(square.getFillColor());
Ensure your loops start at 0 and end at GRID_SIZE - 1 . You need to iterate over each row, and
Here is how the logic translates into standard Java code, which is typical for AP Computer Science A courses on CodeHS:
var x = col * SQUARE_SIZE; var y = row * SQUARE_SIZE; var square = new Rectangle(SQUARE_SIZE, SQUARE_SIZE); square.setPosition(x, y); // The "Checkerboard" Logic if ((row + col) % 2 == 0) square.setColor(COLOR_ONE); else square.setColor(COLOR_TWO); add(square); Use code with caution. Common Pitfalls to Avoid
Do your specific CodeHS autograder instructions require (like "black" / "white" ) or integers ( 0 / 1 )?
Some CodeHS courses use a console-based "ASCII art" version. This uses text characters instead of graphics.
