9.1.6 Checkerboard | V1 Codehs
grid, a checkerboard pattern alternates colors. If you look at the coordinates of any square: Square (0,0) is Color A. Square (0,1) is Color B. Square (1,0) is Color B. Square (1,1) is Color A.
: Use a for loop to go through each row index ( i ) and column index ( j ).
So, why is the 9.1.6 Checkerboard V1 so important? This project holds significant value for several reasons:
Here is a standard way to write the program: 9.1.6 checkerboard v1 codehs
Karel starts at (1, 1), facing East, with an infinite bag of beepers.
To successfully complete this exercise, you must understand the following Python concepts:
for i in range(8): # Only modify the top 3 and bottom 3 rows if i < 3 or i > 4: for j in range(8): # If the sum of indices is even, set to 1 if (i + j) % 2 == 0: board[i][j] = 1 Use code with caution. Copied to clipboard 3. Print the Result grid, a checkerboard pattern alternates colors
# Pass this function a list of lists, and it will # print it such that it looks like the grids in the exercise instructions. def print_board(board): for i in range(len(board)): # This line uses some Python you haven't learned yet. # It turns each cell into a string and joins them with a space. print(" ".join([str(x) for x in board[i]]))
This condition is the key to the board layout. It checks if the current row should contain pieces:
// Calculate the top-left corner of the square int x = col * SQUARE_SIZE; int y = row * SQUARE_SIZE; Square (1,0) is Color B
Creating a 9.1.6 Checkerboard V1 program in CodeHS requires a solid understanding of and 2D arrays (or grids). This exercise is a classic milestone in Java or JavaScript curriculum because it forces you to think about how coordinates interact.
Are you required to use specified by your teacher's instructions?

