Closest value in a sorted list
Write closest(items, target) that returns the value in the non-empty sorted list
items closest to target. If two values are equally close, return the smaller.
closest([1, 4, 6, 9], 5) -> 4
closest([1, 4, 6, 9], 7) -> 6
closest([1, 4, 6, 9], 100) -> 9
The point is to practise using the insertion position: the answer is one of the two
values either side of where target would go.
def closest(items, target):
...