# (a) A3-6 defect bookkeeping: def(nu) = n_1(nu) for nu in {0,1,2}^m, |nu|=k, using <rho, pair_j> = 2m+2-4j and D = dim O_top + eps
from fractions import Fraction as Fr
from itertools import product
def check(m):
    bad=[]
    for k in range(1,2*m):
        eps=k%2
        nus=[tuple(sorted(nu,reverse=True)) for nu in product(range(3),repeat=m) if sum(nu)==k]
        nus=sorted(set(nus))
        top=tuple(sorted([2]*(k//2)+[eps]+[0]*(m-k//2-1),reverse=True)) if k//2+1<=m else None
        rho=lambda nu: sum(nu[j]*(2*m+2-4*(j+1)) for j in range(m))
        for nu in nus:
            n1=nu.count(1); f=n1*(n1+1)//2
            c=eps+rho(top)-rho(nu)
            d=2*f-c
            if d!=n1: bad.append((k,nu,d,n1))
    return bad
for m in (2,3,4): print('m=%d defect(nu)==n_1(nu) failures:'%m,check(m))
# (b) A3-1 point counts: forms mod t^3 over F_2 on 4-space with v(Pf)=2, by type.
q=2; N=3
import itertools
R=lambda c: c%q
# a form = 6 coefficients (01,02,03,12,13,23), each a polynomial mod t^3 (3 coeffs)
pairs=[(0,1),(0,2),(0,3),(1,2),(1,3),(2,3)]
def pf(w):  # Pf = w01 w23 - w02 w13 + w03 w12 as polynomials mod t^3
    def mul(a,b): return [sum(a[i]*b[j] for i in range(3) for j in range(3) if i+j==d)%q for d in range(3)]
    def add(a,b,s=1): return [(x+s*y)%q for x,y in zip(a,b)]
    return add(add(mul(w[0],w[5]),mul(w[1],w[4]),-1),mul(w[2],w[3]))
def val(p):
    for d in range(3):
        if p[d]: return d
    return 3
cnt={}
for coeffs in itertools.product(itertools.product(range(q),repeat=3),repeat=6):
    w=[list(c) for c in coeffs]
    if val(pf(w))!=2: continue
    w0=[c[0] for c in w]
    typ='(1,1)' if not any(w0) else '(2,0)'
    cnt[typ]=cnt.get(typ,0)+1
print('F_2, N=3: #O^(3)_(2,0) =',cnt.get('(2,0)'),'(claimed 35840); #O^(3)_(1,1) =',cnt.get('(1,1)'),'(claimed 1792)')
