Solution to an interview task