Finding the closest side length to a given value