import json, math
R=json.load(open('survey.json'))
def P(n):
    p,b=2,1
    while n>1:
        while n%p==0: n//=p; b=p
        p+=1
    return b
def spf(n):
    p=2
    while n%p: p+=1
    return p
bad=[]
for r in R:
    g=r['group']; k0=r['k0']; N=r['order']
    if k0 is None:
        assert g.startswith('C') and r['axis']=='elt'; continue
    if not (3<=k0<=max(4,P(N))): bad.append(('boundB',r))
    if g.startswith('Dic'):
        n=int(g[3:])
        if r['axis']=='elt' and r['slice_order']==2*n and n>2:
            exp=4 if n==3 else 3
            if k0!=exp: bad.append(('dicmain',r))
            if n!=3:
                c=sum(math.sin(3*math.pi*k/n) for k in range(1,n) if n/3<k<2*n/3)/(3*n)
                if abs(c-r['c1'][1])>1e-8 or abs(r['c1'][0])>1e-8: bad.append(('c1',r,c))
        elif r['axis']=='elt' and r['slice_order']==4 and n>2:
            exp=3 if n%2==0 else spf(n)
            if k0!=exp: bad.append(('dicj',r))
            if n%2 and abs(complex(*r['c1']))>1e-9 and exp!=3: bad.append(('dicj c1',r))
print("rows",len(R),"violations",bad)
out={}
std={'2T':6,'2O':8,'2I':10}
for r in R:
    g=r['group']
    if r['axis']!='elt': continue
    if g in std and r['slice_order']==std[g] or g.startswith('Dic') and r['slice_order']==max(4,2*int(g[3:])):
        out[g]=(r['k0'],r['c1'])
print({k:v for k,v in out.items() if k in std or k in('Dic2','Dic3','Dic4')})
