916 Checkerboard V1 Codehs Fixed Updated Jun 2026
Row 0: R B R B R B R B Row 1: B R B R B R B R Row 2: R B R B R B R B ... and so on.
/* * This program draws a checkerboard pattern. * The "Fixed" version ensures that rows alternate * regardless of the grid dimensions. */ 916 checkerboard v1 codehs fixed
The most common mistake in "v1" is only checking if the column is even or odd. If you do that, every row will look identical, resulting in vertical stripes rather than a checkerboard. Use the sum of the row and column indices. If (row + col) is even , color it Red. If (row + col) is odd , color it Black. The Corrected Code (JavaScript/Karel Style) Row 0: R B R B R B
function start() for (var row = 0; row < ROWS; row++) for (var col = 0; col < COLS; col++) var x = col * SQUARE_SIZE; var y = row * SQUARE_SIZE; * The "Fixed" version ensures that rows alternate
: The inner loop ( for j in range(8) ) goes through every column in those specific rows and changes the value from 0 to 1 .
y -= SIZE # FIX: Decrement row_count row_count -= 1