def triplet_occurrence(iterable, triplet_sum):
    """
    A triplet is said to be present if any of the three numbers in the iterable is equal to given triplet_sum
    :param iterable: Iterable should be either of the types list or tuple of minimum length 3 with numbers
    :param triplet_sum: Triplet sum should be a number
    :return: True if triplet is present, else False

        Eg: triplet_occurrence([1, 4, 45, 10, 6, 8], 22) gives True
            Here 4, 10 and 8 adds up to give 22 which is the given triplet_sum.
    """
    if type(iterable) == list or type(iterable) == tuple:
        pass
    else:
        raise TypeError('Iterable should be of either list or tuple')
    for item in iterable:
        if not isinstance(item, int):
            raise ValueError('Only numbers are accepted in the iterable')
    if not isinstance(triplet_sum, int):
        raise ValueError('Triplet sum should be a number')
    if len(iterable) < 3:
        raise Exception(
            'Length of the given iterable should be of minimum length 3')
    iterable = list(iterable)
    iterable.sort()
    low = 0
    mid = 1
    high = len(iterable) - 1
    current_sum = iterable[low] + iterable[mid] + iterable[high]
    occur = dict()
    occur[iterable[low] + iterable[high]] = [iterable[low], iterable[high]]
    occur[iterable[mid] + iterable[high]] = [iterable[mid], iterable[high]]
    while mid < high:
        if current_sum == triplet_sum:
            return True
        elif current_sum < triplet_sum:
            if mid - low == 1:
                mid += 1
                if triplet_sum - iterable[mid] in occur.keys():
                    return True
                occur[iterable[high] + iterable[mid]] = [iterable[mid],
                    iterable[high]]
                occur[iterable[low] + iterable[mid]] = [iterable[low],
                    iterable[mid]]
                current_sum += iterable[mid] - iterable[mid - 1]
            else:
                low += 1
                if triplet_sum - iterable[low] in occur.keys():
                    return True
                occur[iterable[high] + iterable[low]] = [iterable[low],
                    iterable[high]]
                occur[iterable[mid] + iterable[low]] = [iterable[low],
                    iterable[mid]]
                current_sum += iterable[low] - iterable[low - 1]
        else:
            high -= 1
            occur[iterable[high] + iterable[low]] = [iterable[low],
                iterable[high]]
            occur[iterable[high] + iterable[mid]] = [iterable[mid],
                iterable[high]]
            if triplet_sum - iterable[high] in occur.keys():
                return True
            current_sum += iterable[high] - iterable[high + 1]
    return False
