def apriori_gen(L: list, k):
    L_next = list()
    for l1 in L:
        for l2 in L:
            if (len((set(l1) & set(l2))) == (k - 1)):
                L_next.append(sorted(list((set(l1) | set(l2)))))
    L_set = set((tuple(x) for x in L_next))
    L_k1 = [list(x) for x in L_set]
    L_k1.sort(key=(lambda x: L_next.index(x)))
    L_k1_tuple = [tuple(i) for i in L_k1]
    info = {'join': len(L_k1)}
    for c in L_k1_tuple:
        if has_infrequent_subset(c, L):
            L_k1.remove(list(c))
    info['prune'] = len(L_k1)
    return (info, L_k1)
def apriori_gen(L: list, k):
    L_next = list()
    for l1 in L:
        for l2 in L:
            if (len((set(l1) & set(l2))) == (k - 1)):
                L_next.append(sorted(list((set(l1) | set(l2)))))
    L_set = set((tuple(x) for x in L_next))
    L_k1 = [list(x) for x in L_set]
    L_k1.sort(key=(lambda x: L_next.index(x)))
    L_k1_tuple = [tuple(i) for i in L_k1]
    info = {'join': len(L_k1)}
    for c in L_k1_tuple:
        if has_infrequent_subset(c, L):
            L_k1.remove(list(c))
    info['prune'] = len(L_k1)
    return (info, L_k1)