def iter3d(n):
    """
    Generate all possible unordered combinations of vectors i,j,k
    for i,j,k < n

    This looping was rewritten thanks to:
    TAOCP V4 fascicle 3, section 7.2.1.3.
    
    It gives much nicer ordering than previously, as is gradually
    expands down the list, instead of hammering the start
    """
    for k in range(2, n):
        for j in range(1, k):
            for i in range(j):
                yield i, j, k
