from fractions import Fraction as Q from itertools import product def run(load,check): E=Q(25,23);J=Q(300,299);rows=[];trials=[] def aff(a,k):return(k,(1-k)*a) def comp(a,b):return(a[0]*b[0],a[0]*b[1]+a[1]) def at(f,x):return f[0]*x+f[1] for t,row in enumerate(load('PREVIOUS_DATA.json')['rows']): A,B,x,y,N=row['original_tuple'];z=Q(row['E_image_input']);w=Q(row['E_image_output_with_next_Noah']);D=Q(row['required_J_pivot']);h=y-x left=comp(aff(N+h,E),aff(A,J));right=comp(aff(D,J),aff(N,E)) check('whole affine square '+str(t),left==right and left[0]==Q(7500,6877) and at(left,x)==w) check('unique whole-map pivot '+str(t),D==N+E*(A-N)+(E-1)*h/(J-1)) check('Shem geometry and forty-two '+str(t),(N-z,w-D,z-D,N+h-D,N-A,A+h-D)==(500,600,598,1100,1058,42)) passed=[] for k,eps in enumerate(product([Q(-1,4),Q(1,4)],repeat=8)): nn,np,aa,xx,yy,zz,ww,dd=[Q(v)+e for v,e in zip([N,N+h,A,x,y,z,w,D],eps)] ok=(at(aff(nn,E),xx)==zz and at(aff(np,E),yy)==ww and at(aff(aa,J),xx)==yy and at(aff(dd,J),zz)==ww) if ok:passed.append(list(map(str,eps))) if ok:check('successful component affine square '+str((t,k)),comp(aff(np,E),aff(aa,J))==comp(aff(dd,J),aff(nn,E))) trials.append({'row':t,'assignment_index':k,'offsets':list(map(str,eps)),'all_four_edges_source_exact':ok}) check('only two coherent component assignments '+str(t),len(passed)==2 and all(len(set(p))==1 for p in passed)) rows.append({'row':t,'source_input':x,'MT_output':y,'E_input_image':str(z),'final_Shem_birth':str(w),'first_Noah_center':N,'next_Noah_center':N+h,'original_J_Flood_pivot':A,'transported_J_Shem_death_pivot':str(D),'equal_affine_coefficients':list(map(str,left)),'source_partition':[500,600],'next_outer_span':1100,'original_outer_span':1058,'outer_span_difference':42,'passed_component_assignments':passed}) check('1024 phase assignments',len(trials)==1024 and sum(x['all_four_edges_source_exact'] for x in trials)==8) check('fixed composite does not preserve half-year spacing',(E*J-1)*Q(1,2)==Q(623,13754)>0) return {'step':'C386','rows':rows,'phase_trials':trials,'counts':{'whole_affine_source_squares':4,'context_lifts':8,'phase_assignments':1024,'source_exact_component_squares':8},'identity':'E_(N+h) o J_A = J_D o E_N, where D=E_N(A)+26h=A-40 for the sourced h2, N-A1058 cases.','physical_half_year_spacing_excess':str((E*J-1)/2),'physical_composite_slope':str(E*J),'interpretation':'The sourced E/J square is an exact affine identity and has two matched-component realizations per coordinate square. Using separate phase-shifted source pivots preserves those comparisons; one fixed physical-time affine map stretches seasonal separation. Its500+600 geometry reaches1100, forty-two above the original1058 side, so it is not the old2K-side-preserving repair.'}