import mpmath as mp
mp.mp.dps=30
target = 0.1200/0.02237  # 5.3643

# Broad grammar: (a*B1 + b*B2 + c)/(d*B3 + e) over the LIVE bricks ONLY (no 19, no 16-via-19)
# Live integer bricks the corpus actually uses post-supersession:
live = {'Ngen':3,'nnz':57,'kmax':60,'dimM7':7,'b3':1,'spinor16':16,'e8':8,
        'h0O2':6,'h0O3':10,'h0O4':15,'gauge12':12,'tau1':1,'l31':31}
import itertools
names=list(live.keys())
hits=set()
for n1 in names:
  for n2 in names:
    for add in [0,1,-1,2,-2,3,-3]:
      num=live[n1]+0
      den=live[n2]+add
      if den<=0: continue
      v=num/den
      if abs(v-target)/target<0.01:
        hits.add((live[n1],live[n2],add,round(v,4)))
# simple single-brick ratios
for n1 in names:
  for n2 in names:
    v=live[n1]/live[n2]
    if abs(v-target)/target<0.01:
      hits.add((live[n1],live[n2],0,round(v,4)))
print("Live-brick ratios within 1% of 5.3643:")
for h in sorted(hits,key=lambda x:abs(x[3]-target)):
  print(f"  {h[0]}/({h[1]}+{h[2]}) = {h[3]}")
print()
print("spinor16/Ngen =",16/3,"  <- only clean hit; 16 from 12+3+1 index, 3=chi(CP2)")
