from collections import defaultdict,Counter from fractions import Fraction def run(load,read,check): r=load('C286_DATA.json')['target_register'];ix=defaultdict(list) for i,z in enumerate(r):ix[z['center']].append(i) C=[3188,3190,3248,3250];pivots=sorted({c+s*432 for c in C for s in [-1,1]});arrows=[];groups=[];fail=[] for h in pivots: check(f'sourced_pivot_{h}',h in ix);counts=Counter() for x in sorted(ix): n=25*x-2*h;y=Fraction(n,23) category='fractional' if y.denominator!=1 else ('sourced' if int(y) in ix else 'integer_absent') counts[category]+=1 if category=='sourced': z=int(y);arrows.append({'pivot':h,'input':x,'output':z,'gap_from_pivot':x-h,'change':z-x,'input_indices':ix[x],'output_indices':ix[z],'pivot_indices':ix[h]}) check(f'gap_ratio_{h}_{x}',23*(z-h)==25*(x-h)) else:fail.append({'pivot':h,'input':x,'output_numerator':n,'output_denominator':23,'category':category}) groups.append({'pivot':h,**dict(counts),'nonzero_arrows':sum(a['pivot']==h and a['input']!=a['output'] for a in arrows)}) return {'step':'C450','pivots':pivots,'arrows':arrows,'failures':fail,'pivot_summary':groups,'counts':{'trials':8*len(ix),'sourced_arrows':len(arrows),'nonzero_arrows':sum(a['change']!=0 for a in arrows),'distinct_nonzero_edges':len({(a['input'],a['output']) for a in arrows if a['change']!=0}),'fractional':sum(x['category']=='fractional' for x in fail),'integer_absent':sum(x['category']=='integer_absent' for x in fail)}}