(hour_list)
return sorted(hours)
Returns a list with gaps in it fixed.

    Args:
        hour_list: a list of integers in a sequence, potentially
            with holes in the sequence.

    Returns:
        A list that consists of the input numbers with single
        integer gaps filled. The list should not have more than
        two runs. Therefore if there are more than two runs after
        all gaps have been filled the "extra" runs will be dropped.
Returns a list with gaps in it fixed.
Returns a list with gaps in it fixed .
def fix_gap_in_list(hour_list):
    """Returns a list with gaps in it fixed.

    Args:
        hour_list: a list of integers in a sequence, potentially
            with holes in the sequence.

    Returns:
        A list that consists of the input numbers with single
        integer gaps filled. The list should not have more than
        two runs. Therefore if there are more than two runs after
        all gaps have been filled the "extra" runs will be dropped.
    """
    if not hour_list:
        return hour_list

    runs = get_list_of_consecutive_sequences(hour_list)
    len_runs = len(runs)

    for i in range(0, len_runs - 1):
        _, upper = runs[i]
        next_lower, _ = runs[i+1]
        if (upper + 1) == (next_lower - 1):
            hour_list.append(upper + 1)

    hours = sorted(hour_list)
    runs = get_list_of_consecutive_sequences(hour_list)

    if len(runs) <= 2:
        return hours
    if len_runs < len(runs):
        return fix_gap_in_list(hours)

    # Now we need to remove runs, we only need the first and last.
    run_start = runs[0]
    run_end = runs[-1]
    hours = list(range(0, run_start[1] + 1))
    hours.extend(range(run_end[0], run_end[1] + 1))

    return sorted(hours)
def fix_gap_in_list ( hour_list ) : if not hour_list : return hour_list runs = get_list_of_consecutive_sequences ( hour_list ) len_runs = len ( runs ) for i in range ( 0 , len_runs - 1 ) : _ , upper = runs [ i ] next_lower , _ = runs [ i + 1 ] if ( upper + 1 ) == ( next_lower - 1 ) : hour_list . append ( upper + 1 ) hours = sorted ( hour_list ) runs = get_list_of_consecutive_sequences ( hour_list ) if len ( runs ) <= 2 : return hours if len_runs < len ( runs ) : return fix_gap_in_list ( hours ) # Now we need to remove runs, we only need the first and last. run_start = runs [ 0 ] run_end = runs [ - 1 ] hours = list ( range ( 0 , run_start [ 1 ] + 1 ) ) hours . extend ( range ( run_end [ 0 ] , run_end [ 1 ] + 1 ) ) return sorted ( hours )