def permute(a):
    """
    Creates all unique combinations of a list a that is passed in.
    Function is based off of a function written by John Lettman:
    TCHS Computer Information Systems.  My thanks to him.
    """
    a.sort()
    yield list(a)
    i = 0
    first = 0
    alen = len(a)
    while True:
        i = alen - 1
        while True:
            i -= 1
            if a[i] < a[i + 1]:
                j = alen - 1
                while not a[i] < a[j]:
                    j -= 1
                a[i], a[j] = a[j], a[i]
                t = a[i + 1:alen]
                t.reverse()
                a[i + 1:alen] = t
                yield list(a)
                break
            if i == first:
                a.reverse()
                return
