import re


def get_hours(hours):
    """
    STILT results are availabe in 3 hour times slots: 0 3 6 9 12 15 18 21
    You may choose to return only results for a specific time slot.
    Selection of hours: Input is expected to be a list or convertible to a list
    where each item can be casted to integer in the range of 0 to 23.
    
    If hours is empty or None, ALL Timeslots are returned.
    Valid results are returned as result with LOWER BOUND values.
    Example:    hours = [2,3,4] will return Timeslots for 0, 3 
                hours = [2,3,4,5,6] will return Timeslots for 0,3 and 6
                hours = [] return ALL
                hours = [10] returns timeslot 9
    """
    
    
    valid = [0,3,6,9,12,15,18,21,24]
    valid_hours = []
    for h in hours:
        # for back compatibility, we need to check input for str format
        # hh:mm -> convert to int
        if isinstance(h, str):
            if re.match('[0-9][0-9]:[0-9][0-9]', h):
                h = h[0:2]
                
        h = int(h)
        if h < 0 or h > 24:
            pass
        for i in range(0,8):
            if h >= valid[i] and h < valid[i+1]:
                valid_hours.append(valid[i])
                break                
    # make sure we have unique values
    valid_hours = list(set(valid_hours))
    
    if not hours:
        # return ALL in case no hours or only invalid hours are provided
        return valid[0:8]
    else:
        return valid_hours