9.1.6 Checkerboard V1 Codehs Review
Example (pseudocode):
for r in 0..7:
line = ""
for c in 0..7:
if (r + c) % 2 == 0:
line += "#"
else:
line += " "
print(line)
Graphical (canvas/turtle) output:
Using helper functions (CodeHS libraries):
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 Modulo Operator (%):
Setting the Color:
Grid Integration:
Using the parity rule (r + c) % 2 determines cell contents and yields a simple, provably correct O(n^2) algorithm. The provided textual and graphical templates adapt to typical CodeHS environments. If you supply the exact CodeHS problem text or target language/API (e.g., Java, JavaScript, CodeHS turtle), I will produce a tailored solution and classroom-ready explanation matching that context.
Problem: The squares are outlined but not colored.
Fix: You must call both setFillColor() and setFilled(true). 9.1.6 checkerboard v1 codehs
for row in board: print(row)
Alternatively, if you want a more visual representation:
# Initialize the board
board = []