def pairs_generator(rng):
    """
    Creates Generator of ordered pairs
    :param rng : Range of the interval, e.g. 3 means pairs (0,1),(0,2),(1,2)
    :return:
    """
    return ((i, j) for i in range(rng) for j in range(rng) if i < j)