Algorithms excercise 1