from fractions import Fraction from collections import defaultdict import hashlib def run(load,read,check): cert=load('C429_CERTIFICATE.json');check('C429_data_certificate',hashlib.sha256(read('C429_DATA.json').encode()).hexdigest()==cert['data_sha256']);check('C429_report_certificate',hashlib.sha256(read('C429_REPORT.md').encode()).hexdigest()==cert['report_sha256']) r=load('C286_DATA.json')['target_register'];ix=defaultdict(list) for i,z in enumerate(r):ix[z['center']].append(i) def E(h,x):return Fraction(25*x-2*h,23) def profile(name,inputs,pivots): rows=[list(map(Fraction,inputs))] for h in pivots:rows.append([E(h,x) for x in rows[-1]]) return {'name':name,'pivots':pivots,'stages':[[str(x) for x in row] for row in rows],'stage_membership':[[x.denominator==1 and int(x) in ix for x in row] for row in rows],'pivot_membership':[h in ix for h in pivots],'fully_sourced':all(h in ix for h in pivots) and all(x.denominator==1 and int(x) in ix for row in rows for x in row)} original=profile('original_Shem_split',[2148,3206],[3620,2756]);translated=profile('translated_split_only',[2648,3706],[4120,3256]);held=profile('inherited_Noah_held',[2648,3706],[3706,3706]) for x in [0,1,2648,3706]:check('whole_map_'+str(x),E(3256,E(4120,x))==E(3706,E(3706,x))) old=next(x for x in load('C429_DATA.json')['complete_fixed_pivot_E2_ladders'] if x['held_upper']==3706) check('matches_C429',old['input_lower']==2648 and old['E_intermediate']['numerator']==2556 and old['output']['numerator']==2456) row=next(x for x in load('C287_DATA.json')['rows'] if x['i']==3);check('inherited_C287_corner',row['R']==2648 and row['Noah_required']==3706 and row['S']==-6345 and row['F']==-5287 and 3706-row['F']==2648-row['S']==17*529) needed=sorted({int(Fraction(x)) for p in [original,translated,held] for stage in p['stages'] for x in stage}|{h for p in [original,translated,held] for h in p['pivots']}) return {'step':'C474','profiles':[original,translated,held],'overall_map':{'slope':'625/529','effective_pivot':3706,'intercept':str(-Fraction(96*3706,529))},'source_resolution':[{'coordinate':x,'record_indices':ix.get(x,[]),'records':[r[i] for i in ix.get(x,[])]} for x in needed],'inherited_C429_ladder':old,'inherited_C287_row':row,'counts':{'profiles':3,'complete_profiles':sum(p['fully_sourced'] for p in [original,translated,held])},'menu_note':'The3706-held calculation is the inherited C429 fixed-upper diagnostic. It is not added to the active eight-pivot E menu.'}