
Robbie also has 9 friends with him at point X, and his job is to get a po-boy for each of his friends and return to point X to dine with them. He can only carry one meal at a time, which is of no consequence, since Robbie is, of course, only a robot. However, Robbie is to travel the shortest distance possible, considering the state of the one-way streets as he travels. On one trip he may be able to move east on 2nd Avenue, while on another he may have to take another route.
Your job is to present Robbie's task as a formal algorithm.
A formal algorithm is written ALGORITHM (Name) {commands}, and
in an algorithm we write lots of comments (lines beginning with an !) so
that humans can figure out what is going on at any point in the algorighm.
For example, if Robbie wants to take a walk around Acme from point X one
could write,
ALGORITHM (Circle Walk)
! This algorithm describes what Robbie does to take a walk around his favorite
! restaurant at point Y, starting with a southward move from point X.
! Move down to 1st Avenue.
{SOUTH;
! Can't go up C Street since it's one-way in the wrong direction.
REPEAT (3)
{EAST;
};
! Now continue north, then west, and then south back to the starting
! point.
REPEAT (2)
{NORTH;
};
REPEAT (3)
{WEST;
};
REPEAT (2)
{SOUTH;
};
}
Notice the consistent use of indentation, punctuation, blank lines, comments,
and other documentation to make the formal algorithm into an unambiguous
statement of what Robbie does to accomplish the assigned task.