def combine(intervals):
    """combine overlapping and adjacent intervals.

    >>> combine([(10,20), (30,40)])
    [(10, 20), (30, 40)]
    >>> combine([(10,20), (20,40)])
    [(10, 40)]
    >>> combine([(10,20), (15,40)])
    [(10, 40)]
    """
    if not intervals:
        return []

    new_intervals = []

    intervals.sort()
    first_from, last_to = intervals[0]

    for this_from, this_to in intervals[1:]:
        if this_from > last_to:
            new_intervals.append((first_from, last_to))
            first_from, last_to = this_from, this_to
            continue

        if last_to < this_to:
            last_to = this_to

    new_intervals.append((first_from, last_to))

    return new_intervals