from itertools import product def run(load,check): reg=load('C286_DATA.json')['target_register'];profiles=load('C416_DATA.json')['profiles'];events=[] for p in profiles: c=p['context'];e=[] for i,r in enumerate(reg): if r['role'].startswith('Flood') and all(r.get(k)==c[k] for k in ['tradition','Cainan','Terah60','full430']):e.append({'record_index':i,'record':r,'selected_Gear':r['gear']==c['gear']}) check('six event records '+c['tradition'],len(e)==6);events.append(e) fixed=[];trials=[] for u,l in product(*events): a,z=u['record'],l['record'];d=a['center']-z['center'];row={'upper_record_index':u['record_index'],'lower_record_index':l['record_index'],'upper_role':a['role'],'lower_role':z['role'],'upper_Gear':a['gear'],'lower_Gear':z['gear'],'difference':d,'same_boundary':a['role']==z['role'],'two_K':d==1058,'both_selected_Gears':u['selected_Gear'] and l['selected_Gear']};trials.append(row) if row['same_boundary']:check('same-boundary parity '+str((u['record_index'],l['record_index'])),d%2==1 and d!=1058) if row['both_selected_Gears']:fixed.append(row) mixed=next(x for x in fixed if x['two_K']);check('selected mixed-boundary match',mixed['upper_role']=='Flood close' and mixed['lower_role']=='Flood start') augmented=[] for p,e,role in zip(profiles,events,['Flood close','Flood start']): f=next(x for x in e if x['selected_Gear'] and x['record']['role']==role);s={r:x['record']['center'] for r,x in p['stations'].items()};s['selected Flood boundary']=f['record']['center'];order=['Noah birth','Shem birth','selected Flood boundary','Noah death','Shem death'];partition=[s[order[i]]-s[order[i+1]] for i in range(4)];check('selected five-station partition '+p['context']['tradition'],partition==[500,100,350,150]);augmented.append({'context':p['context'],'Flood_role':role,'Flood_record_index':f['record_index'],'stations':s,'partition':partition}) images=[] for u in events[0]: if not u['selected_Gear']:continue x=u['record']['center']-1058;matches=[i for i,r in enumerate(reg) if r['center']==x];images.append({'upper_event':u,'required_coordinate':x,'all_source_record_indices':matches,'lower_context_event_matches':[e for e in events[1] if e['record']['center']==x]}) return {'step':'C418','fixed_Gear_boundary_matrix':fixed,'all_event_Gear_trials':trials,'five_station_comparison':augmented,'translated_Flood_event_images':images,'counts':{'fixed_Gear_boundary_pairs':len(fixed),'all_event_Gear_boundary_pairs':len(trials),'same_boundary_trials':sum(r['same_boundary'] for r in trials),'same_boundary_2K_hits':sum(r['same_boundary'] and r['two_K'] for r in trials),'mixed_boundary_2K_hits_all_Gears':sum(r['two_K'] for r in trials)},'interpretation':'The selected close/start boundary adds a fifth2K station and common500+100+350+150 partition. Both like-named Flood boundaries differ1059 at the selected Gears; even Gear changes cannot repair the odd difference to1058. Upper start3300 translates to MT Gear2 close2242, while upper close3299 translates to MT Gear1 start2241. These coordinates do not form a single same-Gear same-boundary MT Flood year. The valid500/100 and502/98 source modes are not revoked.'}