My efforts to learn Processing always seem to get tripped up by my poor math skills. I am also not sure if I’m using the correct terminology, so I’m hoping someone can either help me, or at least point me toward the correct question to ask. (Or search for)

I’m trying to divide a sketch vertically into even horizontal bands. I’m starting out playing by drawing random vertical lines throughout a band, and I’d like there to be multiple bands of these vertical lines. For example, if I put in hard values for only 3 bands I’d do:

```
for (int i = 0; i < width; i++) {
float p = random(width);
line(p, 0, p, height/3);
}
for (int j = 0; j < width; j++) {
float q = random(width);
line(q, height/3, q, 2*height/3);
}
for (int k = 0; k < width; k++) {
float r = random(width);
line(r, 2*height/3, r, height);
}
```

I get into trouble when I’d like to just be able to specify how many bands I want, and let loops do the job for me. I don’t understand how the math would work.

My instinct is to try something like:

```
int bands = 3;
for (int n = 0; n < bands-1; n++) {
for (int i = 0; i < width; i++) {
float p = random(width);
line(p, ??????, p, ??????);
}
}
```

But I can’t get my head around how to setup the Y coordinates for the lines so it would work with any number of bands I choose. Am I at least on the right track? Is there a simpler way?

I’m just starting out on my coding journey so any suggestions at all would be much appreciated.

Thank you for reading!