Algorithms 1, Princeton, task 3