Boats to carry everyone

weights lists people's weights; each boat carries at most two people and at most limit total weight, and nobody weighs more than limit. Write boats(weights, limit) that returns the fewest boats.

boats([1, 2], 3)        ->  1
boats([3, 2, 2, 1], 3)  ->  3
boats([3, 5, 3, 4], 5)  ->  4

The point is to practise the pairing greedy: the heaviest person goes with the lightest if they fit, otherwise alone.

def boats(weights, limit):
    ...