All distinct pairs with a sum

items is sorted and may contain repeats. Write pairs_with_sum(items, target) that returns every distinct pair [a, b] with a <= b and a + b == target, in increasing order of a. Each distinct pair appears once even if the values repeat.

pairs_with_sum([1, 1, 2, 3, 3, 4, 5], 6)  ->  [[1, 5], [2, 4], [3, 3]]
pairs_with_sum([1, 2], 10)                ->  []

The point is to practise two pointers with a skip past repeated values after a match.

def pairs_with_sum(items, target):
    ...