9.1.6 Checkerboard V1 Codehs -

Core observation: parity (even/odd) of row+column determines which symbol to place.

Algorithm (textual):

Proof of correctness:

Complexity analysis:

The Checkerboard v1 problem teaches:

The solution demonstrates how to create an alternating pattern without knowing the grid size in advance, an essential concept in robotics and grid-based programming.

The challenge is deciding when to use gray and when to use black. There is a simple mathematical trick: look at the sum of the row index and column index. 9.1.6 checkerboard v1 codehs

Let's test this:

This pattern creates a perfect checkerboard.

We solve the problem by:

Pseudo-code:

function start():
    turn off beeper auto-placement
    var row = 1
    while (front is clear or left is clear):
        placeRow(row)
        if (front is clear):
            moveToNextRow()
        row++

The objective is to create a checkerboard pattern using a 2D array logic concept. You are usually provided with a Rectangle class and a Checkerboard class (which uses Grid).

In "Checkerboard v1", the standard logic is to determine the color of a square based on the sum of its row and column indices. Proof of correctness:

Problem: The canvas is 400×400, but squares don't align perfectly.
Fix: Calculate the window size dynamically from the square size and number of squares, as shown in the constants above.

You need one loop for the rows and another loop for the columns. For each row (y-position), you will iterate through all columns (x-positions).

app store qr
K-POP의 모든 것! 케이타운포유
앱에서만 제공되는 할인 혜택을 받아 보세요!

QR코드 스캔하고
케이타운포유 앱으로 보기
app store qr
App Store
play store qr
Google Play