Add implementation for the third exercise.