An interview exercise I've been asked to implement