Menu

Sections thématiques

9.1.6 Checkerboard V1 Codehs !!top!!

La méthode SMART dans le mode de management demeure un levier intéressant pour mener à bien sa mission de manager. Encore faut-il que tout cela repose sur une base solide et fiable. Quels sont les apports de la méthode S.M.A.R.T en management ? Comment fixer des objectifs SMART ? Définition et illustration par un exemple

Rédigé par Laurent GRANGER - Mis à jour le 11/11/2025

9.1.6 Checkerboard V1 Codehs !!top!!

Report: CodeHS 9.1.6 Checkerboard v1

1. Overview

Course: CodeHS Introduction to Programming (JavaScript)
Module: 9.1 - Karel Challenges
Problem: 9.1.6 Checkerboard v1
Objective: Write a Karel program that places a checkerboard pattern of beepers on a rectangular world of any size (within Karel’s limits).

Example (JavaScript-like pseudocode for CodeHS canvas)

var size = 8;
var S = 40; // pixel square size
for (var r = 0; r < size; r++) 
  for (var c = 0; c < size; c++) 
    var x = c * S;
    var y = r * S;
    if ((r + c) % 2 === 0) 
      fillRect(x, y, S, S); // filled square
     else 
      // leave background or draw empty square

5. Implementation Notes for CodeHS (JavaScript Graphics)

If using CodeHS JavaScript (graphics):

: Forgetting that the middle two rows (index 3 and 4 in an 8-row grid) must remain empty (0s). Bypassing Assignment 9.1.6 checkerboard v1 codehs

This exercise is designed to test your ability to work with 2D lists (lists of lists) and nested for loops. A common mistake is just printing the pattern; however, the CodeHS autograder specifically checks if you have assigned the value 1 to elements within your board. 1. Initialize Your Grid Report: CodeHS 9

  • Define square size S and start coordinates.
  • Nested loops; compute x = startX + cS, y = startY + rS.
  • If (r + c) % 2 == 0, draw filled rectangle at (x,y) of size S, else skip or draw outline/background.
  • Optionally set colors for filled/empty squares.
// Optional: return to start turnAround(); while (frontIsClear()) move();

Algorithmic approach

Core observation: parity (even/odd) of row+column determines which symbol to place. Define square size S and start coordinates