def is_weekend_worked(x, wkend_type, i):
    """
    Determine if i'th weekend is worked (full or half) for a given
    weekend pattern x and weekend type,

    :param x: list of 2-tuples representing weekend days worked. Each list
            element is one week. The tuple of binary values represent the
            first and second day of the weekend for that week. A 1 means
            the day is worked, a 0 means it is off.
    :param wkend_type: 1 --> weekend consists of Saturday and Sunday
                       2 --> weekend consists of Friday and Saturday
    :type wkend_type: int
    :param i: which weekend to check
    :type i: int
    :return: True if weekend i is worked, False otherwise

    Example:
        b = is_weekend_worked([(0,1),(1,0),(0,1),(1,0)],1,1)
        # b = True

        b = is_weekend_worked([(0,1),(1,0),(0,1),(1,0)],1,2)
        # b = False

        b = is_weekend_worked([(1,0),(1,0),(1,1),(1,0)],2,1)
        # b = True

        b = is_weekend_worked([(0,1),(1,0),(0,1),(0,0)],2,4)
        # b = False

    """
    if wkend_type == 2:
        if sum(x[i - 1]):
            return True
        else:
            return False
    else:
        n_weeks = len(x)
        if i < n_weeks:
            sunday_idx = i
        else:
            sunday_idx = 0

        if (x[i - 1][1] + x[sunday_idx][0]) > 0:
            return True
        else:
            return False