def find_contained_positions_unopt(X, Y):
    """ Find mapping of positions contained within non-overlapping segments (unopt)

    Args:
        X (numpy.array): start and end of non-overlapping segments with shape (N,2) for N segments
        Y (numpy.array): positions with shape (M,) for M positions

    Returns:
        numpy.array: M length array of indices into X containing elements in Y

    X is assumed to be ordered by start position.

    For positions not contained within any segment, value in returned array will be -1

    """
    M = [-1] * Y.shape[0]
    for x_idx, x in enumerate(X):
        for y_idx, y in enumerate(Y):
            if Y[y_idx] >= x[0] and Y[y_idx] < x[1]:
                assert M[y_idx] == -1
                M[y_idx] = x_idx
    return M
