CS2121 lab exercise 1 part a9 - hint

This is obviously related to part a2, but requires a significantly more complex answer - you should also look back at part a7.
Try thinking about the problem again. Start by thinking about what you want to achieve and how you might go about achieving it, even if you don't know exactly how to write it down.

If you are still stuck, here are some more hints.