from fractions import Fraction as Q def run(load,check): reg=load('C286_DATA.json')['target_register'];rows=[] for f in load('C349_DATA.json')['fields']: z=f['records'];i=f['i'];N=z['N']['center'];S=z['S'];H=z['H'];g=S['gear'] def pick(t,role,gear,c,terah,rail=None): x=[r for r in reg if r['tradition']==t and r['role']==role and r['gear']==gear and r['Cainan']==c and r['Terah60']==terah and r['full430']==1 and r.get('rail')==rail];assert len(x)==1;return x[0] T=pick('SP','Shem death',g,0,0,'primary');L=pick('MT','Shem death',g,0,0);A=pick('MT','Shem death',g+1,1,1) check('matched Shem rectangle '+str(i),S['center']-T['center']==H['center']-L['center']==600 and S['center']-H['center']==T['center']-L['center']==650) check('fifty gap and1250 span '+str(i),T['center']-H['center']==50 and S['center']-L['center']==1250 and 600+50+600==1250) check('branch totals '+str(i),N-T['center']==1100 and N-H['center']==1150) check('source500 translation '+str(i),S['center']==N-500 and A['center']==z['R']['center']-500 and L['center']==z['F']['center']-500) check('translated2K input '+str(i),S['center']-A['center']==1058 and A['center']-L['center']==192) mid=Q(S['center'])+Q(25,23)*(A['center']-S['center']);out=Q(S['center'])+Q(625,529)*(A['center']-S['center']);middle=[r for r in reg if r['center']==mid] check('direct squared E endpoint '+str(i),out==L['center'] and Q(S['center'])+Q(25,23)*(mid-S['center'])==out) check('unadmitted intermediate '+str(i),mid==z['H']['center']-500 and not middle) check('gap comparison ancestry '+str(i),Q(598)*Q(25,23)==650 and Q(598)*Q(300,299)==600 and Q(650)-600==50) rows.append({'i':i,'S_SP_birth':S,'T_SP_death':T,'H_MT_birth':H,'L_MT_death':L,'A_restored_next_Gear_MT_death':A,'ordered_gaps':[600,50,600],'SP_to_MT_birth_offset':650,'matched_lifespans':600,'outer_span':1250,'Noah_to_SP_death':1100,'Noah_to_MT_birth':1150,'squared_E':{'pivot':S,'input':A,'output':L,'input_gap':1058,'output_gap':1250,'intermediate_coordinate':str(mid),'intermediate_matches':middle,'direct_endpoint_match':True,'two_source_edges':False},'translation':-500}) return {'step':'C361','rows':rows,'interpretation':'The50 fork is650 source offset minus600 lifespan. The1250 birth-to-death span supplies a translated squared-E endpoint comparison. Its1150 intermediate width has no admitted endpoint in the frozen register, so it is not a composable two-edge source path.','new_source_nodes':False}