def binary_search(target, source):
    """ Binary search the position of target in the source set.
    """
    N = len(source)
    start = 0
    end = N-1

    while (end - start) != 1:
        mid = start + (end - start)//2

        if target <= source[mid]:
            end = mid
        else:
            start = mid

    return start