9.1.7 Checkerboard V2 Answers
logic is the most efficient way to solve version 2 of this problem. In "v1," you might have only alternated colors per row, but adding the row and column indices together ensures that if you are on an even row, the pattern starts with "Color A," and if you are on an odd row, it starts with "Color B." ✅ Final Result The answer is achieved by using nested for loops combined with the conditional statement if (row + col) % 2 == 0
A checkerboard follows a simple :
: The outer loop tracks the row index, while the inner loop tracks the col index to access every individual element in the 2D list. 9.1.7 checkerboard v2 answers
def print_board(self): for row in self.board: for cell in row: if cell is None: print('-', end=' ') else: print(cell.color[0].upper(), end=' ') print() logic is the most efficient way to solve
| Error Message / Symptom | Likely Cause | Solution | |-------------------------|--------------|----------| | Square is not filled | Missing setFilled(true) | Add the line before setting the color. | | All squares are the same color | Incorrect modulus logic | Use (row + col) % 2 == 0 . Check your starting color. | | ArrayIndexOutOfBoundsException | Using <= instead of < in loop | Ensure loops run 0 to 7 (not 0 to 8 ). | | Nothing appears on screen | Forgot to call add(square) | After creating and coloring, call add(square) . | | Squares overlap or have gaps | Incorrect coordinate math | x = col * size , y = row * size . Don’t add extra offset. | | Autograder fails on style | Missing constants or comments | Use private static final int for magic numbers (8, 50). | | | All squares are the same color
Start by creating a 2D list (grid) that contains 8 rows and 8 columns, with all elements initially set to 0. 2. Iterate Through Rows and Columns
Loop again, using x = col * 50 , y = row * 50 , create GRect , set fill color from board[row][col] , and add(square) .

5 Comments
how to download file to different directory using curl.
Use -o with curl command to save file in other directory. Like:
I don’t know who you are but THANK YOU!!!!!!!!!!!!!!!
Hi ,
/usr/bin/curl”,”-k”,”-u”,userName+”:”+password,”\””+hostIP+”\””,”-o” ,csvDownloadPath+”ggggg.csv”
I am using this command , where i am doing wrong, we are not getting any error in logs, running this command in java ,on linux server.
try{
ProcessBuilder pb = new ProcessBuilder(“/usr/bin/curl”,”-k”,”-u”,userName+”:”+password,”\””+hostIP+”\””,”-o” ,csvDownloadPath+”ggggg.csv”);
Process p = pb.start();
InputStream is = p.getInputStream();
System.out.println(“command running “);
}
catch(Exception e){
e.printStackTrace();
System.out.println(“command running through “);
Actually running this…
plz guide me , Thanks In advance