Code
size (300,300);
background (255,200,200);
int spacing = 21;
for (int x=50; x<250; x+=spacing) {
for (int y=50; y<250; y+=spacing) {
if ((y % 2) == 0) {
ellipse (x,y, 15,15);
}else {
ellipse (x+(spacing/2),y, 15,15);
}
}
}
/* The solution to the excersize above works only if the spacing number is odd. If the spacing number is even, like 20, the remainder will never be 0.
*/
0201 - Nested Iteration I: A grid of elements, some indented
Statement:"Nested iteration" refers to the idea of setting up a repetition of repetitions. Reread the section on "Nested Iteration" described on pages 65-67 in the Reas & Fry Processing book.
Use nested iteration to create a grid of small ellipses, such that even rows are indented by one-half of your grid's spacing. You must not use separate for{} loops for the odd and even rows. An example of such a design can be seen here:

Hint: A number N is odd if it has 1 left over after dividing by 2 -- that is, if (N%2 == 1). Likewise, a number is even if it has no remainder after dividing by 2. In other words, I'd prefer you to solve this problem by writing a detector for odd and even numbers. Do you understand? See the last example on page 66 for some more hints.