Q1. Familiarizing with programming concepts
Your task is to “program” the self-driving car as shown in Figure 1 so it can drive itself to the destination (the green cell) in the shortest way and with the smallest number of instructions. The are 5 instructions that you can use to program the car:
• LEFT – the car will turn left
• RIGHT – the car will turn right
• DRIVE – the car will move forward 1 cell if the cell is empty
• REVERSE– the car will move backward 1 cell if the cell is empty.
• REPEAT #N – repeat the command following the REPEAT command N times or until the car hits an obstacle or hits the wall. For example, REPEAT 5; DRIVE; will repeat the DRIVE command 5 times.
An example of how to write your program is given below. Note that you must follow the coding syntax.
Students succeed in their courses by connecting and communicating with an expert until they receive help on their questions
Consult our trusted tutors.