Solution to closest numbers problem.