A bit leaner:
size(500,500);int x=0,y=0;while(y<height){int r=int(random(2))*25;line(x+r,y,x+25-r,y+25);x+=25;if(x>width){y+=25;x=0;}}
size(500, 500);
int x=0, y=0;
while (y<height) {
int r=int(random(2))*25;
line(x+r, y, x+25-r, y+25);
x+=25;
if (x>width) {
y+=25;
x=0;
}
}