def ff(items, targets):
    """First-Fit

    This is perhaps the simplest packing heuristic;
    it simply packs items in the next available bin.

    Complexity O(n^2)
    """
    bins = [(target, []) for target in targets]
    skip = []

    for item in items:
        for target, content in bins:
            if item <= (target - sum(content)):
                content.append(item)
                break
        else:
            skip.append(item)
    return bins, skip
def ff ( items , targets ) : bins = [ ( target , [ ] ) for target in targets ] skip = [ ] for item in items : for target , content in bins : if item <= ( target - sum ( content ) ) : content . append ( item ) break else : skip . append ( item ) return bins , skip
First-Fit

    This is perhaps the simplest packing heuristic;
    it simply packs items in the next available bin.

    Complexity O(n^2)