<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def subset(self, interval: Interval, flexibility: int = 2) -> "IntervalList": """ Returns an IntervalList that's a subset of this one, only containing intervals that meet the "interval" parameter criterion. What "meet" means is defined by the ``flexibility`` parameter. ``flexibility == 0``: permits only wholly contained intervals: .. code-block:: none interval: intervals in self that will/won't be returned: N---N N---N Y---Y N---N N---N N---N N---N ``flexibility == 1``: permits overlapping intervals as well: .. code-block:: none N---N Y---Y Y---Y Y---Y N---N N---N N---N ``flexibility == 2``: permits adjoining intervals as well: .. code-block:: none N---N Y---Y Y---Y Y---Y N---N Y---Y Y---Y """

        if flexibility not in [0, 1, 2]:
            raise ValueError("subset: bad flexibility value")
        permitted = []
        for i in self.intervals:
            if flexibility == 0:
                ok = i.start > interval.start and i.end < interval.end
            elif flexibility == 1:
                ok = i.end > interval.start and i.start < interval.end
            else:
                ok = i.end >= interval.start and i.start <= interval.end
            if ok:
                permitted.append(i)
        return IntervalList(permitted)