Completed code for interview exercise.