In the grid, the black squares represent obstacles to Cupid, who
cannot go through them; nor can Cupid step outside the grid
boundaries.
A square grid with \(4\) rows and \(4\) squares in each row. We number the rows from top to bottom, and number the squares in each row from left to right.
Cupid is in the first square in the second row, and his arrow
points toward the second square in the second row.
There is a heart in the fourth square in the third row.
In the first row, the second square is black.
In the second row, the fourth square is black.
In the third row, the third square is black.
In the fourth row, no squares are black.
There is a compass with North toward the top of the
grid.
Let’s play with some pseudocode to guide Cupid’s
path to the heart. The code will use the following instructions:
fly1: moves Cupid one square in
the current arrow direction