Representing algorithms

EasyMediumHard
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
Question 33
Medium

A robot is placed in a 5x5 grid. The robot's starting position is shown in the grid below by the arrow symbol ▼ at Row 2, Column 2, which indicates it is initially facing South (Down).

Squares containing an [Obstacle] cannot be moved into. The outer boundary of the grid also acts as an obstacle that cannot be moved into (i.e. ObjectAhead() evaluates to true if the robot is facing the edge of the grid).

Robot Grid

Robot Algorithm

WHILE ObjectAhead() = true
  TurnLeft()
  IF ObjectAhead() = true THEN
    TurnRight()
    TurnRight()
  ENDIF
  Forward(1)
ENDWHILE
Forward(1)

Determine the sequential path of coordinates the robot visits from start to finish. Specify each step in order using the format (Row, Column).

[3]

Representing algorithms Questions

  1. GCSE
  2. /Computer Science
  3. /Representing algorithms