Instructions

DIRECTIONS for the following questions:

These questions are based on the situation given below: A robot moves on a graph sheet with x and y-axes. The robot is moved by feeding it with a sequence of instructions. The different instructions that can be used in moving it, and their meanings are: Instruction Meaning GOTO(x,y) move to point with coordinates (x, y) no matter where you are currently WALKX(P) Move parallel to the x-axis through a distance of p, in the positive direction if p is positive, and in the negative direction if p is negative WALKY(P) Move parallel to the y-axis through a distance of p, in the positive direction if p is positive, and in the negative direction if p is negative.

Question 46

The robot reaches point (6, 6) when a sequence of three instructions is executed, the first of which is a GOTO(x, y) instruction, the second is WALKX(2) and the third is WALKY(4). What are the values of x and y?

Solution

Before, the third instruction, the point on which the robot is present is (6,2).

Before, the second instruction, the point on which the robot is present is (4,2).

Hence, the values of x and y are 4 and 2 respectively.