Notebook: loops with conditionals

What loop will solve each of these problems?

  1. Travel across 14 squares, picking up a ball from any square that has a ball there
  2. Travel stairs of uneven widths (all with a height of 1) across a world that is 10 squares wide.
    uneven squares

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 


1)
for (var p=0;p<14;p++){
  if(ballPresent())
     takeBall();
  move();
}   
  
  2)
  for(var w=0;w<10;w++){
     if(frontIsClear())
        move();
     else {
        turnLeft();
        move();
        turnRight();
        move();
      }
   }