X and Y are next to each other, if X is right of Y or if X is left of Y.
X
Y
Solution
Back to the exercise.