This is my algorithm exercise.