Answer:
start();
if(colorIs(Color.blue)){
paint(Color.red);
if(frontIsClear());
move();
}else{
if(colorIs(Color.red)){
paint(Color.blue);
if(frontIsClear());
move();
}
}
if(colorIs(Color.blue)){
paint(Color.red);
if(frontIsClear());
move();
}else{
if(colorIs(Color.red)){
paint(Color.blue);
if(frontIsClear());
move();
}
}
if(colorIs(Color.blue)){
paint(Color.red);
if(frontIsClear());
move();
}else{
if(colorIs(Color.red)){
paint(Color.blue);
if(frontIsClear());
move();
}
}
if(colorIs(Color.blue)){
paint(Color.red);
if(frontIsClear());
move();
}else{
if(colorIs(Color.red)){
paint(Color.blue);
if(frontIsClear());
move();
}
}
if(colorIs(Color.blue)){
paint(Color.red);
if(frontIsClear());
move();
}else{
if(colorIs(Color.red)){
paint(Color.blue);
if(frontIsClear());
move();
}
}
if(colorIs(Color.blue)){
paint(Color.red);
if(frontIsClear());
move();
}else{
if(colorIs(Color.red)){
paint(Color.blue);
if(frontIsClear());
move();
}
}
if(colorIs(Color.blue)){
paint(Color.red);
if(frontIsClear());
move();
}else{
if(colorIs(Color.red)){
paint(Color.blue);
if(frontIsClear());
move();
}
}
if(colorIs(Color.blue)){
paint(Color.red);
if(frontIsClear());
move();
}else{
if(colorIs(Color.red)){
paint(Color.blue);
if(frontIsClear());
move();
}
}
if(colorIs(Color.blue)){
paint(Color.red);
if(frontIsClear());
move();
}else{
if(colorIs(Color.red)){
paint(Color.blue);
if(frontIsClear());
move();
}
}
if(colorIs(Color.blue)){
paint(Color.red);
if(frontIsClear());
}else{
if(colorIs(Color.red)){
paint(Color.blue);
if(frontIsClear());
}
}
function start(){
}
Q. 5.1.3: Move to Wall
Ans:
function start(){
while(frontIsClear()){
move();
}
}
I apologize if its incorrect