Load the truck

boxes is a list of (count, units_per_box) and the truck holds at most capacity boxes. Write max_units(boxes, capacity) that returns the most units you can load.

max_units([(1, 3), (2, 2), (3, 1)], 4)  ->  8     (1x3 + 2x2 + 1x1)
max_units([(5, 10)], 2)                 ->  20

The point is to practise the simplest greedy: sort by value and take as much as fits.

def max_units(boxes, capacity):
    ...